From patchwork Thu Sep 24 02:59:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=D77jco5A; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Whf3p9tM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSd4zVwz1xyS for ; Thu, 24 Sep 2026 22:59:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5523440D9D; Thu, 24 Sep 2026 12:59:44 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id cxpH-MyCK4kO; Thu, 24 Sep 2026 12:59:42 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp4.osuosl.org 6A1CE40CAA Authentication-Results: smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254782; b=dZdrbzq7nTimxF95IF+hd0Z9PpZbTqn+rONYG4O06CRmzgn6LrGRLqV2Uly/7ctIUa44 3WSc9nGbZcapvjzGW1r4YhNQ6gYK/GWAQ2NSQGp9iUYw2bJnyWXQdgMzXlI7hs5fXNzdX esDj+6moBvbsGDQHhL2uENvdXCnl11IL5waQMM59wiWdr9xSU4kI5PD7JwNDoiU0m1wGh Y5M9ZO15gTYB6q/x6s5h6lqchdS00smNAkA8bKpZfoVwk0FfaVEo2jUa9DeciT0OOVCWz HhX0enRERFYb0S8Gd+2eyEIh63/8fpAbufP9KwpvjrTF1a0ysxsnDIcDc5/t07o0tOA== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254782; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=FIQlEUFlSPuubbK2RoxRbBGR9SjJqreDr2oCk6es1ck=; b=BH/tbs2f2YCCzidqRh5WJQwbXmsCMFXYEBrCsajZtfJme9Vo3hqRs9YEYQd3sio82GAo +MAPn0iXCBOKRSDX/lRvb1bmLEpykjNwnkxl8AcXQSSoCy4e4+E+0OigMqheZVye1xNoQ 1D1U+mRBm88MigvcfiELt7910PhgFNBSClskRLHbfVhR00d5rqnIuUP/2xmhrLOQ4Rtmm 4C/eI7m1LMriA7O4QXhQv2AduLE6gnffcxXYVHgEg4aQkxmStQlMaZ3LGRhtYE1Le8LpC BCwJKtoqeMOthR89k26U4+AL0CtKFmHrA0H080qsJlnfqAJU381qTKBES6rsnpIV2Vg== ARC-Authentication-Results: i=2; smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254782; bh=FIQlEUFlSPuubbK2RoxRbBGR9SjJqreDr2oCk6es1ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D77jco5A2G3mVStJrs9f9ATAruLubMm0IfZsTulWJ1PbUaQ7gwarWbOgLdkw0qalI JmT4HBDrWj2d5LEm45zvtXIChAAVBu3orGDNVYwDyI1RwfyH2po+dxXgWU3m9IeooG KbRbUL+drNPVb+Pgby+JYlFVK/cb/bkSoS23c3DFDZJ3xzn7R4GD9WO6BvLcAAbHDo /buX3w/wS5S9qWgK5jK0BsifLi8ScB8PIV9+8oOhsPdqxz6zg5HxXZOwe6x4gWeCet z0iw4sbN1u9MhbaMq9ClkDnQQyFbjHF1PD2CJuPTZxIZh3BLXImpz866q5gIHOTOM1 WKr3e3wfhjbwg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 6A1CE40CAA; Thu, 24 Sep 2026 12:59:42 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id BB7FE194 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AC8FA6082A for ; Thu, 24 Sep 2026 12:59:31 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 00IbmHpuQNl1 for ; Thu, 24 Sep 2026 12:59:31 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org C19BF60807 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254771; b=Rio5uMV4fTRG7RqUxaan5Iww8EmxHarkYQBLfRHLdYL3yxfzxCHEyhecwgF1CFy53aEB /nnRe0kzjbfRGSJeoBdt3WIwXfCJnMZnXowpIvN3zLRbJmJKiCcoQUzPK1GSaDG5CmNOI AInFz7dctjQynkNzyxn0SO/Z9jXQKwXKsKCoRu77Bx8ZEgkk1R4hF16jbuPmBRbJMoDok hGkfJ4RIbG4tqN9KfxbHOrQO0mfV+EV4IOk/xue6ZU3+bZUT8pN0KZYlqK5kpjiCfY4PQ 6ntQJNVTb+P8CSioPgrIW3la8jv+Qst0qIn1U2TTc7sm8jz736N4FTxXwvr/bD86M5Q== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254771; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=FIQlEUFlSPuubbK2RoxRbBGR9SjJqreDr2oCk6es1ck=; b=KuZxSLDtLNJn+YdoPXsl5+w64aMRdyHsl9D0Th7x6WYrhUSvuIq3ySrqUFELyPYzhi9Y 1THDXvcwe6yJFAdttxmy97ss7olKUFQ2Yl0ihky9XngL+UWcTGE5ryFVz3aeJBMLEdylY s1evbMVBPApl5v5Zma1v7zPjq2a1Q68gZLTpb+34fr1TPyo7Bf9A3G4QtQQC5gcuDPiee mH7+0e2hfb0aDSVJWHlNOrBDAsUApUdsActeOUTtEtaB7zRE7iizILAYT9zkBaiKMOCyg ZyNpTimCxMCWu/NSZT9wP/D0nXk54MhWe9NfpoofEClJeRbTPZABJhz62KuoA4rImnw== ARC-Authentication-Results: i=1; smtp3.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Whf3p9tM; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Whf3p9tM Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp3.osuosl.org (Postfix) with ESMTPS id C19BF60807 for ; Thu, 24 Sep 2026 12:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254771; x=1821790771; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0tf+p1G4D3ewn7KDhH/n7CLlgziNzxiJx9suljYesq0=; b=Whf3p9tMvXJU3JwBFrEok8tSaZA6UWyd/H0qhGimbxn35vBxBmH2RMZv DXNxQbOKUXB1ZZ9m+CxaJZBZsdIg2coQ4aYSBCPl0KfqdfhM5115NuCr6 zksObUFI1Qs7999ViKcR/IKXCmMxVuu5+CyEipmVMgfopsFwk6Wd22b7C /oHljXbHX0txpFMhLfK38SGkNLnT1+Iwqfns0v2N+wSo+lbZ1yICGmo5/ QEv/0SE+GSwOyZfHjU3DCNxsNKIVqqYFDvrUh/4sUJt9jK7cRlD4XcCLe +LTihmDAZsbvQSfQkhgEuK2wE4ZwTGnl3WHCHdoqDTKe35vhKQVI+I1Be Q==; X-CSE-ConnectionGUID: td3bs50uQXGL8z/16wUlpA== X-CSE-MsgGUID: bfFyC2dySySsgjRqSCOyag== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249215" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249215" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:19 -0700 X-CSE-ConnectionGUID: Xley8Jw9QrOW76oTx4Cunw== X-CSE-MsgGUID: lY7UqxcBRxivS2vcLB1msQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934423" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:18 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 1/8] ice: Unlink the PTP port before destroying its ps_lock Date: Thu, 24 Sep 2026 12:59:09 +0000 Message-ID: <20260924125916.2796499-2-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org err_clean_pf destroys ptp->port.ps_lock before ice_ptp_cleanup_pf() removes the port from adapter->ports.list and drains the outstanding references, so while the mutex is being destroyed the port is still reachable by every other PF on the adapter: ice_ptp_settime64() ice_ptp_restart_all_phy() list_for_each_entry_rcu(port, &pf->adapter->ports.list, list_node) ice_ptp_port_phy_restart(port) mutex_lock(&ptp_port->ps_lock); ice_ptp_setup_pf() publishes the port before ice_ptp_init_port() runs, and a link event can set port.link_up at any point after that, so the walk does not necessarily skip it. Call ice_ptp_cleanup_pf() first and destroy the mutex once no other PF can reach the port, matching the order already used by the ICE_PTP_READY path in ice_ptp_release(). Release the Tx timestamp tracker here as well, so the label frees everything the port owns. ice_ptp_init_port() allocates it through ice_ptp_alloc_tx_tracker(), and any failure unwinding through err_clean_pf after that point would otherwise leak tx->tstamps, tx->in_use and tx->stale. The tx.init guard is needed because err_clean_pf is also reached when ice_ptp_init_port() itself fails, and ice_ptp_alloc_tx_tracker() leaves tx->lock uninitialized in that case. Fixes: 23a5b9b12de9 ("ice: fix PTP cleanup on driver removal in error path") Signed-off-by: Sergey Temerkhanov Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/ice/ice_ptp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index a735dfa2b03e..5104ccc70d4c 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -3587,8 +3587,14 @@ void ice_ptp_init(struct ice_pf *pf) return; err_clean_pf: - mutex_destroy(&ptp->port.ps_lock); + /* Unlink the port before tearing down anything it still shares with + * the other PFs on the adapter: ice_ptp_restart_all_phy() can be + * walking adapter->ports.list and taking ps_lock until this returns. + */ ice_ptp_cleanup_pf(pf); + if (ptp->port.tx.init) + ice_ptp_release_tx_tracker(pf, &ptp->port.tx); + mutex_destroy(&ptp->port.ps_lock); err_exit: /* If we registered a PTP clock, release it */ if (pf->ptp.clock) { From patchwork Thu Sep 24 02:59:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310784 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=LVv98HJr; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=htKUrgKz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSS3gJVz1xyS for ; Thu, 24 Sep 2026 22:59:36 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D391A81971; Thu, 24 Sep 2026 12:59:34 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ojBasaptpL2C; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 88E7B8197D Authentication-Results: smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254773; b=LFejvZ3cD8SNgWZDM4b7jCmD2B2T6c0aprKs4ZNb7euQGFCXofa8oB8Vgzk4ge+o29U0 RJ8jW1CuSAuthGVHEruLAvwuveVQv7z5G74M7Vn1COrKKL65ZChzGhblEReoRVbpPOoP4 /k7M79/wrMiLNVrh5+g1/fMLgGG12kwsEAeWCGBM8iBGH1mcveBtHx4jrwJxmYA3Oe7zW kuHaMleFiihcbK6wDK0nQzzI34r+congb8OZX6YPKEKXJszf+XVlonCtb5h+PWyJ73bw+ xxiLckQttqsjO7vLLaxiVFXIrUww30601J2O0cquDwemKniVOJeAxCS3CmQCBq9LjDg== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254773; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=g2+ogjz+uuB8Xv/0BCq9j58g6MJsbZiWuQ5gb7hj+Q0=; b=U3BjCCNPaQfgv0anO1rIEwo7JVqDyUtMFaP1VSBfRScwllWwlmcv/ThKEDHAnRWDOhNO cxQUYNQTZN/GEVaiVX9ZFlO491anIjYqct0Iuo35unNEO1GyvKECBqrd7ruu665f2sTu/ OjUb0ERIGwSq8wVVDefhJbCgmgr78/t8RGAx4j2j8KmVsoe+Ij7TTpGdUjwcDX+t6qVxe N3QnOd8lgJPWnEkZTXnbOjxsN6ESf6bDUHZRuVxJ+QPwHyUkE07zY/kgaYf+Q/VHIMT6I 6xXwHbT80lqKSBsvAjuL5y6NV6aQqhmtA4dzPigTVa2hYTU5AoQEOyf3x6YHE5MWD1g== ARC-Authentication-Results: i=2; smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254773; bh=g2+ogjz+uuB8Xv/0BCq9j58g6MJsbZiWuQ5gb7hj+Q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LVv98HJrAe4HHJ3MlHGEWsWahMYi+6C0a/uCPbsTrCxGHPfq2qyKsVZL+pAXVwUMX slV/Z7ql0lhIWw2CUAGUBLrBZjuz0WPwe4AmWsM3M3s2vlTb5fIrDClMhNklb6RSmS aqkM0o2chg8MskqJiTgvrKjcRRVJP4IK5Fv9aZrOU5DfZWcCSzKGlQrttPM5VEFhmO vQ7WujlMPdIujUBAqpJednzZgNjKMZZeO9NI7Q/qVf/2QmwnuwPgyXJ5xk1IKJwQO2 qmG3tgYr4b1MVXj0ypmn36icCMMIFYpueB1mnlyfw/EnjQCIeqrhQUi60cMnD1KKdk 1nxNiFI3hu5Yg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 88E7B8197D; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id 96889194 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8853560838 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2YmsaRngvLQW for ; Thu, 24 Sep 2026 12:59:31 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org 504F260824 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254771; b=VSl5LljDWOAcHSpcBlTAmacAbK4AYCBU+xG3xHpzqMsIEIHC8OuCjDhoeoBmgsOryMLe 76jKTmzUQ9FHLIVf33O9ikr8T5PCNsbaqzvq68Z5u0qf8UNAWBYs21bR4K10xYlhbnEW+ BaKU0C3a2zj2N+LcP5/WpXn24p+wwvzsLpRfoQC11kl7+ynV9EUieT0RRyDRIhNNua47L RoP46Z7+MeQnc8H4FT/S009onxwrWgFHGZAUqQmB6lgUJWim/BJbUHPyQEIIcv2clHanu nyPSYG3fELIhdlfeEwOWiq1cUB/FNKlSeJKrEghZS7z6Tsav19zIDJSCF9sQzhgAsNg== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254771; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=g2+ogjz+uuB8Xv/0BCq9j58g6MJsbZiWuQ5gb7hj+Q0=; b=cvcgr+AePAa9H0tIsKzxoJodxqcIRoraJ7PhPqOgPat2X4YwwTIo0hSX9ekhCtLMB35h mf4/hptrzUkBaIJqlQK6/9jOI4AFsnpjGJbjbZA6R4TdRffQZTmgTeNmFu0Y7n5hzWN3v CMIuoF4Mm6Yxp6lSlXoNuIagcdV78aT7tjK9groX5LV72VWBWwjQEv/PMfFI0jgI3hCGp 9FQMbTP5eTA6qmKQ3L6xWF0etYm3Crwo6YyusrlhxBgaEr20Nrfm8fbbb6LWVImhd0HLQ Q2b/DB+vO0NsC3Y6tpOh4+HA1LiakXMba7oYocvZgcicDS1UlnWs1T1iup3z8o9aafg== ARC-Authentication-Results: i=1; smtp3.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=htKUrgKz; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=htKUrgKz Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp3.osuosl.org (Postfix) with ESMTPS id 504F260824 for ; Thu, 24 Sep 2026 12:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254771; x=1821790771; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=msXKp6CC/ep+giV26muxkpmdRcbKph8YIsTJZyZZg6Y=; b=htKUrgKzqW0Lc/5hHDBN3A7cGZgUYo9PvzmRh9nSsSzRQAX57FJCnXzP OCRerbFsX37EmpUeUJjvrGi9Avpkayafp/p/LHtDaY3ojPHNmreAViRhI AaOfeMhNfJtp0AIBM3k3WfWNdz9NFZ8u8ly6bzBnXGYOe3CNF97p2b/6h nWV6E14q/AIMDC2Vjdw2KcXBGkh2smZSoRlTMJIkcQTcieNM24LYbHnAn /xnUw/xg3iPaU+z9nWGAmTGlmrACoCBi3DKiWXEirVqaJhYrEcGa61p7f sPunzG3b7ul32nM4OQCvRwrY1cDzSE6NNibBeSC45ip7MpuQwraLriZ7M g==; X-CSE-ConnectionGUID: mcftterxQU+0vGJ3uyTEyg== X-CSE-MsgGUID: dsn8VQQHT0CUQ7HrNXsYjg== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249219" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249219" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:20 -0700 X-CSE-ConnectionGUID: QmPKzMBJQkSSXmbbyXIHHQ== X-CSE-MsgGUID: L96KtBOiSPuKChQeV7fC4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934424" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:19 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 2/8] ice: Protect the control PF pointer with RCU and a rwsem Date: Thu, 24 Sep 2026 12:59:10 +0000 Message-ID: <20260924125916.2796499-3-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Mark adapter->ctrl_pf as __rcu and route every reader through rcu_dereference_check(), publishing it with rcu_assign_pointer(). Readers that can run in an RCU read-side critical section are wrapped accordingly. Add adapter->ctrl_pf_lock for the sleepable users which cannot sit in an RCU read-side critical section, namely the PTP hardware semaphore in ice_ptp_lock()/ice_ptp_unlock() and the TX reference clock paths in ice_txclk.c. Pass the resolved control PF into ice_txclk_enable_peer() so it is looked up once under that lock. The pointer is still only ever published and never cleared, so there is no functional change here. This only puts the annotations and the locking in place for the lifetime handling that follows. Signed-off-by: Sergey Temerkhanov Reviewed-by: Arkadiusz Kubalewski Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/ice/ice.h | 25 +++++- drivers/net/ethernet/intel/ice/ice_adapter.c | 1 + drivers/net/ethernet/intel/ice/ice_adapter.h | 5 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 83 +++++++++++++------- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 23 ++++++ drivers/net/ethernet/intel/ice/ice_txclk.c | 20 +++-- 6 files changed, 120 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 117391f62848..08b40626b876 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -1141,26 +1142,44 @@ static inline bool ice_pf_src_tmr_owned(struct ice_pf *pf) * ice_get_primary_hw - Get pointer to primary ice_hw structure * @pf: pointer to PF structure * + * The function must be called from an RCU read-side critical section or + * while holding adapter->ctrl_pf_lock. + * hw is embedded in struct ice_pf, so either mechanism protects its lifetime. + * * Return: A pointer to ice_hw structure with access to timesync * register space. */ static inline struct ice_hw *ice_get_primary_hw(struct ice_pf *pf) { - if (!pf->adapter->ctrl_pf) + struct ice_pf *ctrl_pf; + + ctrl_pf = rcu_dereference_check(pf->adapter->ctrl_pf, + lockdep_is_held(&pf->adapter->ctrl_pf_lock)); + + if (!ctrl_pf) return &pf->hw; else - return &pf->adapter->ctrl_pf->hw; + return &ctrl_pf->hw; } /** * ice_get_ctrl_pf - Get pointer to Control PF of the adapter * @pf: pointer to the current PF structure * + * The control PF is the PF which owns the PTP clock for the adapter. + * Only the control PF is allowed to perform certain operations on the + * PTP clock such as adjusting the time or configuring the pins. + * + * This function must be called from an RCU read-side critical section or + * while holding adapter->ctrl_pf_lock. + * * Return: A pointer to ice_pf structure which is Control PF, * NULL if it's not initialized yet. */ static inline struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf) { - return !pf->adapter ? NULL : pf->adapter->ctrl_pf; + return !pf->adapter ? NULL : + rcu_dereference_check(pf->adapter->ctrl_pf, + lockdep_is_held(&pf->adapter->ctrl_pf_lock)); } #endif /* _ICE_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.c b/drivers/net/ethernet/intel/ice/ice_adapter.c index ba2a50f0da95..5dc4e5f1c6aa 100644 --- a/drivers/net/ethernet/intel/ice/ice_adapter.c +++ b/drivers/net/ethernet/intel/ice/ice_adapter.c @@ -69,6 +69,7 @@ static struct ice_adapter *ice_adapter_new(struct pci_dev *pdev) spin_lock_init(&adapter->ports.lock); INIT_LIST_HEAD(&adapter->ports.list); + init_rwsem(&adapter->ctrl_pf_lock); return adapter; } diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.h b/drivers/net/ethernet/intel/ice/ice_adapter.h index 6f94c5fd6a88..9de00435bf2b 100644 --- a/drivers/net/ethernet/intel/ice/ice_adapter.h +++ b/drivers/net/ethernet/intel/ice/ice_adapter.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -36,6 +37,7 @@ struct ice_port_list { * @txq_ctx_lock: Spinlock protecting access to the GLCOMM_QTX_CNTX_CTL register * @cpi_phy_lock: Per-PHY mutex serializing CPI REQ/ACK transactions. * Index 0 = PHY0, index 1 = PHY1. Used on E825C devices. + * @ctrl_pf_lock: Protect control PF lifetime for sleepable users * @ctrl_pf: Control PF of the adapter * @rebuild_lock: serialize PFR recovery across PFs of the same adapter * @ports: Ports list @@ -52,7 +54,8 @@ struct ice_adapter { /* Serialize PFR recovery touching shared FW global state */ struct mutex rebuild_lock; - struct ice_pf *ctrl_pf; + struct rw_semaphore ctrl_pf_lock; + struct ice_pf __rcu *ctrl_pf; struct ice_port_list ports; u64 index; }; diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 5104ccc70d4c..455e3af30abe 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2,6 +2,7 @@ /* Copyright (C) 2021, Intel Corporation. */ #include +#include #include #include "ice.h" #include "ice_lib.h" @@ -60,6 +61,19 @@ static const struct ice_ptp_pin_desc ice_pin_desc_dpll[] = { { SDP3, { 3, -1 }, { 0, 0 }}, }; +/** + * ice_get_ctrl_ptp - Get the PTP structure for the control PF + * @pf: The PF pointer to look up at + * + * The control PF is the PF which owns the PTP clock for the adapter. + * Only the control PF is allowed to perform certain operations on the + * PTP clock such as adjusting the time or configuring the pins. + * + * This function must be called from an RCU read-side critical section or + * while holding adapter->ctrl_pf_lock. + * + * Return: Pointer to the PTP structure of the control PF, or NULL if not found + */ static struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf) { struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf); @@ -208,39 +222,42 @@ u64 ice_ptp_read_src_clk_reg(struct ice_pf *pf, u32 hi, lo, lo2; u8 tmr_idx; - if (!ice_is_primary(hw)) - hw = ice_get_primary_hw(pf); - - tmr_idx = ice_get_ptp_src_clock_index(hw); - guard(spinlock)(&pf->adapter->ptp_gltsyn_time_lock); - /* Read the system timestamp pre PHC read */ - ptp_read_system_prets(sts); - - if (hw->mac_type == ICE_MAC_E830) { - u64 clk_time = rd64(hw, E830_GLTSYN_TIME_L(tmr_idx)); + scoped_guard(rcu) { + if (!ice_is_primary(hw)) + hw = ice_get_primary_hw(pf); - /* Read the system timestamp post PHC read */ - ptp_read_system_postts(sts); - - return clk_time; - } + tmr_idx = ice_get_ptp_src_clock_index(hw); + guard(spinlock)(&pf->adapter->ptp_gltsyn_time_lock); + /* Read the system timestamp pre PHC read */ + ptp_read_system_prets(sts); - lo = rd32(hw, GLTSYN_TIME_L(tmr_idx)); + if (hw->mac_type == ICE_MAC_E830) { + u64 clk_time = rd64(hw, E830_GLTSYN_TIME_L(tmr_idx)); - /* Read the system timestamp post PHC read */ - ptp_read_system_postts(sts); + /* Read the system timestamp post PHC read */ + ptp_read_system_postts(sts); - hi = rd32(hw, GLTSYN_TIME_H(tmr_idx)); - lo2 = rd32(hw, GLTSYN_TIME_L(tmr_idx)); + return clk_time; + } - if (lo2 < lo) { - /* if TIME_L rolled over read TIME_L again and update - * system timestamps - */ - ptp_read_system_prets(sts); lo = rd32(hw, GLTSYN_TIME_L(tmr_idx)); + + /* Read the system timestamp post PHC read */ ptp_read_system_postts(sts); + hi = rd32(hw, GLTSYN_TIME_H(tmr_idx)); + lo2 = rd32(hw, GLTSYN_TIME_L(tmr_idx)); + + if (lo2 < lo) { + /* if TIME_L rolled over read TIME_L again and update + * system timestamps + */ + ptp_read_system_prets(sts); + lo = rd32(hw, GLTSYN_TIME_L(tmr_idx)); + ptp_read_system_postts(sts); + hi = rd32(hw, GLTSYN_TIME_H(tmr_idx)); + } + } return ((u64)hi << 32) | lo; @@ -3245,14 +3262,19 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) static void ice_ptp_setup_adapter(struct ice_pf *pf) { - pf->adapter->ctrl_pf = pf; + guard(rwsem_write)(&pf->adapter->ctrl_pf_lock); + + rcu_assign_pointer(pf->adapter->ctrl_pf, pf); } static int ice_ptp_setup_pf(struct ice_pf *pf) { - struct ice_ptp *ctrl_ptp = ice_get_ctrl_ptp(pf); struct ice_ptp *ptp = &pf->ptp; + struct ice_ptp *ctrl_ptp; + + guard(rwsem_read)(&pf->adapter->ctrl_pf_lock); + ctrl_ptp = ice_get_ctrl_ptp(pf); if (!ctrl_ptp) { dev_info(ice_pf_to_dev(pf), "PTP unavailable: no controlling PF\n"); @@ -3327,11 +3349,15 @@ static void ice_ptp_cleanup_pf(struct ice_pf *pf) */ int ice_ptp_clock_index(struct ice_pf *pf) { - struct ice_ptp *ctrl_ptp = ice_get_ctrl_ptp(pf); + struct ice_ptp *ctrl_ptp; struct ptp_clock *clock; + guard(rcu)(); + + ctrl_ptp = ice_get_ctrl_ptp(pf); if (!ctrl_ptp) return -1; + clock = ctrl_ptp->clock; return clock ? ptp_clock_index(clock) : -1; @@ -3595,6 +3621,7 @@ void ice_ptp_init(struct ice_pf *pf) if (ptp->port.tx.init) ice_ptp_release_tx_tracker(pf, &ptp->port.tx); mutex_destroy(&ptp->port.ps_lock); + err_exit: /* If we registered a PTP clock, release it */ if (pf->ptp.clock) { diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c index 881f002daa74..0e138390f8c8 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2021, Intel Corporation. */ +#include #include #include #include "ice_common.h" @@ -335,6 +336,8 @@ void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd) struct ice_pf *pf = container_of(hw, struct ice_pf, hw); u32 cmd_val = ice_ptp_tmr_cmd_to_src_reg(hw, cmd); + guard(rcu)(); + if (!ice_is_primary(hw)) hw = ice_get_primary_hw(pf); @@ -353,6 +356,8 @@ static void ice_ptp_exec_tmr_cmd(struct ice_hw *hw) { struct ice_pf *pf = container_of(hw, struct ice_pf, hw); + guard(rcu)(); + if (!ice_is_primary(hw)) hw = ice_get_primary_hw(pf); @@ -2009,6 +2014,8 @@ static int ice_read_phy_and_phc_time_eth56g(struct ice_hw *hw, u8 port, zo = rd32(hw, GLTSYN_SHTIME_0(tmr_idx)); lo = rd32(hw, GLTSYN_SHTIME_L(tmr_idx)); } else { + guard(rcu)(); + zo = rd32(ice_get_primary_hw(pf), GLTSYN_SHTIME_0(tmr_idx)); lo = rd32(ice_get_primary_hw(pf), GLTSYN_SHTIME_L(tmr_idx)); } @@ -2180,8 +2187,13 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port) lo = rd32(hw, GLTSYN_INCVAL_L(tmr_idx)); hi = rd32(hw, GLTSYN_INCVAL_H(tmr_idx)); } else { + /* cleanup.h advises against mixing goto with scoped helpers, + * and this function unwinds the PTP semaphore with goto below. + */ + rcu_read_lock(); lo = rd32(ice_get_primary_hw(pf), GLTSYN_INCVAL_L(tmr_idx)); hi = rd32(ice_get_primary_hw(pf), GLTSYN_INCVAL_H(tmr_idx)); + rcu_read_unlock(); } incval = (u64)hi << 32 | lo; @@ -5321,6 +5333,9 @@ static void ice_ptp_init_phy_e830(struct ice_ptp_hw *ptp) * * Software must clear the busy bit with a write to release the lock for other * functions when done. + * + * A successful call holds adapter->ctrl_pf_lock for read until + * ice_ptp_unlock() is called. */ bool ice_ptp_lock(struct ice_hw *hw) { @@ -5328,6 +5343,8 @@ bool ice_ptp_lock(struct ice_hw *hw) u32 hw_lock; int i; + down_read(&pf->adapter->ctrl_pf_lock); + if (!ice_is_primary(hw)) hw = ice_get_primary_hw(pf); @@ -5345,6 +5362,9 @@ bool ice_ptp_lock(struct ice_hw *hw) break; } + if (hw_lock) + up_read(&pf->adapter->ctrl_pf_lock); + return !hw_lock; } @@ -5359,10 +5379,13 @@ void ice_ptp_unlock(struct ice_hw *hw) { struct ice_pf *pf = container_of(hw, struct ice_pf, hw); + lockdep_assert_held(&pf->adapter->ctrl_pf_lock); + if (!ice_is_primary(hw)) hw = ice_get_primary_hw(pf); wr32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id), 0); + up_read(&pf->adapter->ctrl_pf_lock); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_txclk.c b/drivers/net/ethernet/intel/ice/ice_txclk.c index 48459f971cbf..4a59ad729547 100644 --- a/drivers/net/ethernet/intel/ice/ice_txclk.c +++ b/drivers/net/ethernet/intel/ice/ice_txclk.c @@ -41,6 +41,7 @@ ice_txclk_get_pin(struct ice_pf *pf, enum ice_e825c_ref_clk ref_clk) /** * ice_txclk_enable_peer - Enable required TX reference clock on peer PHY * @pf: pointer to the PF structure + * @ctrl_pf: control PF protected by adapter->ctrl_pf_lock * @clk: TX reference clock that must be enabled * * Some TX reference clocks on E825-class devices (SyncE and EREF0) must @@ -54,13 +55,15 @@ ice_txclk_get_pin(struct ice_pf *pf, enum ice_e825c_ref_clk ref_clk) * * Return: 0 on success or negative error code on failure. */ -static int ice_txclk_enable_peer(struct ice_pf *pf, enum ice_e825c_ref_clk clk) +static int ice_txclk_enable_peer(struct ice_pf *pf, struct ice_pf *ctrl_pf, + enum ice_e825c_ref_clk clk) { - struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf); bool peer_clk_in_use; u8 port_num, phy; int err; + lockdep_assert_held(&pf->adapter->ctrl_pf_lock); + if (clk == ICE_REF_CLK_ENET) return 0; @@ -118,12 +121,15 @@ static int ice_txclk_enable_peer(struct ice_pf *pf, enum ice_e825c_ref_clk clk) */ int ice_txclk_set_clk(struct ice_pf *pf, enum ice_e825c_ref_clk clk) { - struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf); struct ice_port_info *port_info; + struct ice_pf *ctrl_pf; bool clk_in_use; u8 port_num, phy; int err; + guard(rwsem_read)(&pf->adapter->ctrl_pf_lock); + ctrl_pf = ice_get_ctrl_pf(pf); + if (pf->ptp.port.tx_clk == clk) return 0; @@ -164,7 +170,7 @@ int ice_txclk_set_clk(struct ice_pf *pf, enum ice_e825c_ref_clk clk) mutex_unlock(&ctrl_pf->dplls.lock); if (!clk_in_use) { - err = ice_txclk_enable_peer(pf, clk); + err = ice_txclk_enable_peer(pf, ctrl_pf, clk); if (err) return err; } @@ -215,15 +221,18 @@ int ice_txclk_set_clk(struct ice_pf *pf, enum ice_e825c_ref_clk clk) void ice_txclk_update_and_notify(struct ice_pf *pf) { struct ice_ptp_port *ptp_port = &pf->ptp.port; - struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf); struct dpll_pin *old_pin = NULL; struct dpll_pin *new_pin = NULL; + struct ice_pf *ctrl_pf; struct ice_hw *hw = &pf->hw; enum ice_e825c_ref_clk clk; bool notify_dpll = false; int err; u8 phy; + down_read(&pf->adapter->ctrl_pf_lock); + ctrl_pf = ice_get_ctrl_pf(pf); + phy = ptp_port->port_num / hw->ptp.ports_per_phy; /* Hold txclk_notify_rwsem for read across the entire critical @@ -351,4 +360,5 @@ void ice_txclk_update_and_notify(struct ice_pf *pf) out: up_read(&pf->dplls.txclk_notify_rwsem); + up_read(&pf->adapter->ctrl_pf_lock); } From patchwork Thu Sep 24 02:59:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=6sk9r38h; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=V0Lj31i9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSW043Hz1xyS for ; Thu, 24 Sep 2026 22:59:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8A4BC40CAA; Thu, 24 Sep 2026 12:59:37 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 6loCQ95Z2q-A; Thu, 24 Sep 2026 12:59:37 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp4.osuosl.org CC4CD40CD1 Authentication-Results: smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254776; b=bDFBKApERLdUcMwqRamTidR1RvAL3nvNkyv49Vwd5LJ8qCXnQ+/3gNHStyTNMaQl8tzX MCcG2Cgkl2A+T92Xj/JqDEbf+l3E9TCDImb8x6T/eEzNxhKLXB8lQc0n+hOuWtdK4qr6j 6DBuPbZ1rde/HSnRWITZHYA2E/4DTimwT3HdnfGTsV1j7rbxK5UxO2r9vmhb1TMBBT9ei A9awwMwuBH9pzkKjZyhIlVY50Bq1Phfd5i5S/yNmbRrguqEKmOEIjFaaWWengVku+Sm0G mBZmw6mfqmpSJeCs9aHr7AfRB0v+Qb14xWR2zeQAQwJjbNJGxE6wRrUJFl3x9/eeMDQ== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254776; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=z/J+Kpr21I5RaBfN3Awgd1ygTosfYnt3RzYbtX61gek=; b=PkxWvTxmjVsj8Wers45C2BlAnD6GYT5XQBTtzSPoGp6hUEj/2Pa8s34zH4lsVD6MJQoC ueVqN+9Sf+DkV9ccb0oUJ5o6yZ+6DEeuewUnSzXSI5BMzYVDkTtErUQNqhzQzKNDZ20ww jJwkqI5DO/YL10C23PJfofu8DkSsPS+ubsHoGMfAidvZV4VLaARbUZjDVdG7ti00CO9Cj VbP2u5bYIJLbvwb/ceJ8pEPC9Wkgsbz0K9ygIqhmfFmMKhM2e+M3DOjx0P/X4qYyG+oJi FfS+zIrpqez5N7N8sAMPYkhdHdyBHm2/YWJivD/o5eLoiBn6STvjQRZSuFB00/AbqZg== ARC-Authentication-Results: i=2; smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254776; bh=z/J+Kpr21I5RaBfN3Awgd1ygTosfYnt3RzYbtX61gek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=6sk9r38h/sbsS4/7tgl1+7sFd5U/GsNvaTTB5Ua6H6oDp03ggy8ADKrzKjD6wPqPV kEgwSQD/VXMZxzBMlY7F8XzaYktg4ipA5/chKMq6fLljyaQXgE168gXsYzXCclnreE Ic2dSPXECBNwd4zw4Za4xZBVNX5p2hy4C8ZyXFrvvmyBhNLnokmuOJXAQMPm2+mpwi 02T8xhSDmGTZMHgtuV6o08ZT+Bzia+CO0PbwyTlF4vMzBjK8rPECpR4ej8bsMyFQld Lszy0qVWE0QNAnK3eR+auwMe58qidT8fcnYAhYyXpU0jgi57Jv1GC2kCm6OTv84l0E VpTWcFpoi32YQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id CC4CD40CD1; Thu, 24 Sep 2026 12:59:36 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id CA039194 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BB95840473 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id R2csf6fuMJ_4 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp2.osuosl.org DBA0B400FB Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254772; b=BRL6JCXJiy44QH9pHWOb5+TxhFuSa/WBiMKOErLb32KnLNRmvrDjxFUzx3qWlur4Vqth 2UNUdfqE5wQI46wO5IDHWelpQmPKUFpW/9+GdMp42xASNF0ty0QrmJO6LJqH6ifhLy7Qo TOYb89/Nkvo4P3F57apsmIR0dkJi5M2ck4JPHbvFcNP5aMXEU1vIYJowRNTRuIn/HO9y6 Ci0viLCNny38kZPFOTFi4a6OzYWoKb/UGZqlNIeXRpd+xAlL++bBaWASg3QzBywlqiCx6 auz/xcQAwb/H3dS+bDFWHULeWTEv1BnDTmoxzHrrbE+sQqXWBzLKczszevMiu4+GBvA== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254772; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=z/J+Kpr21I5RaBfN3Awgd1ygTosfYnt3RzYbtX61gek=; b=d1Y46PtbDlqd+nJ0ldseznRvgEdmoY7VfhjXOSqLbgLKbEMo9w8Lmny7q9ubEa3Xg7Tl SZu9iVmsepPvzkuuemVeXJGkNn3pSMnqFMKQuKuKYsvanRCk47V00vC1yUYSuNskgHFhG iMX4CMw9I2vG1QqhaTbLRBwnBZK8FY60atSU6zCMBDBn5hc8TeGD0boDAR9NF6f8D9vXk 9y4l2NvInU1fgUwSpkiR1qqcTlYnhM6MsOUa2ikql5ep4S4ISdfzeWo1dK46ytgyyM79b QRsC2ar9WoOA9C4nDw5Jry1Yvs7ixILV15yggIUsSCl3i770aR3As+tUYsxeNpNUjKQ== ARC-Authentication-Results: i=1; smtp2.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=V0Lj31i9; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=V0Lj31i9 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp2.osuosl.org (Postfix) with ESMTPS id DBA0B400FB for ; Thu, 24 Sep 2026 12:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254772; x=1821790772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LZ9TrTcQM9inz6/eTHV49ReXqnEAzy1K1Bj4zEwKK5E=; b=V0Lj31i94x3PF6g9L/ZMDDfw65Rl7d0OtZMu7qiQr3fsJRcbn6dWPVsl si2IkoWt+C+SPPpmlZ97GwYTVkn6H3toxGXJYsmDitcqtT0zH/mfIqkeU +yrIKURA5i6vLoiSmXl/WziWhrnwIOtPtq+zEGypEvrib4R7NU+z7Sq3d tFsTk++K7QgvddVNfrTE3bkUF8BwaN7M0ihJ4ymtF+UvpIPwQueM0AYZ+ h3+owg/q0kxu/vS21u7dM2aAArI2+Fikgp3ZmP5AznvHEls7XG28W6c3D dYxsBtrq6MHGt9qB55sYWwFLqCKwZc0aR6dbG/E2Bk37GFwKtckAz0D/c w==; X-CSE-ConnectionGUID: wPqtQ789TAKpxk/Tm6cPhA== X-CSE-MsgGUID: 7YzqrF4rSAWKNrw0x7NHcQ== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249224" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249224" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:21 -0700 X-CSE-ConnectionGUID: h+oSSchvRamarbfU0jEiBw== X-CSE-MsgGUID: 62oj8oixS3uo4IEQNG1g+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934425" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:20 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 3/8] ice: Cache struct ice_hw pointer for split register reads Date: Thu, 24 Sep 2026 12:59:11 +0000 Message-ID: <20260924125916.2796499-4-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Cache the primary ice_hw pointer to ensure consistency between calls (both parts of a value will be read from the same NAC). ice_get_primary_hw() will never return NULL, but during the ctrl_pf cleanup there may be a case when one call will return the pointer to the ctrl_pf->hw and the subsequent one - to the pf->hw which generally are not the same. Struct ice_hw is embedded in the struct ice_pf so it is protected by the same critical section - no additional synchronization is needed. Fixes: e2193f9f9ec9 ("ice: enable timesync operation on 2xNAC E825 devices") Signed-off-by: Sergey Temerkhanov Reviewed-by: Aleksandr Loktionov Reviewed-by: Arkadiusz Kubalewski Tested-by: Frederick Lawler --- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c index 0e138390f8c8..38e90a68ba78 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c @@ -4,6 +4,7 @@ #include #include #include +#include "ice.h" #include "ice_common.h" #include "ice_ptp_hw.h" #include "ice_ptp_consts.h" @@ -2014,10 +2015,14 @@ static int ice_read_phy_and_phc_time_eth56g(struct ice_hw *hw, u8 port, zo = rd32(hw, GLTSYN_SHTIME_0(tmr_idx)); lo = rd32(hw, GLTSYN_SHTIME_L(tmr_idx)); } else { + struct ice_hw *pri_hw; + guard(rcu)(); - zo = rd32(ice_get_primary_hw(pf), GLTSYN_SHTIME_0(tmr_idx)); - lo = rd32(ice_get_primary_hw(pf), GLTSYN_SHTIME_L(tmr_idx)); + pri_hw = ice_get_primary_hw(pf); + + zo = rd32(pri_hw, GLTSYN_SHTIME_0(tmr_idx)); + lo = rd32(pri_hw, GLTSYN_SHTIME_L(tmr_idx)); } *phc_time = (u64)lo << 32 | zo; @@ -2187,12 +2192,16 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port) lo = rd32(hw, GLTSYN_INCVAL_L(tmr_idx)); hi = rd32(hw, GLTSYN_INCVAL_H(tmr_idx)); } else { + struct ice_hw *pri_hw; + /* cleanup.h advises against mixing goto with scoped helpers, * and this function unwinds the PTP semaphore with goto below. */ rcu_read_lock(); - lo = rd32(ice_get_primary_hw(pf), GLTSYN_INCVAL_L(tmr_idx)); - hi = rd32(ice_get_primary_hw(pf), GLTSYN_INCVAL_H(tmr_idx)); + pri_hw = ice_get_primary_hw(pf); + + lo = rd32(pri_hw, GLTSYN_INCVAL_L(tmr_idx)); + hi = rd32(pri_hw, GLTSYN_INCVAL_H(tmr_idx)); rcu_read_unlock(); } incval = (u64)hi << 32 | lo; From patchwork Thu Sep 24 02:59:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310786 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=RpBU1aJ3; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jyXTeKNr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSX0vPsz1xyS for ; Thu, 24 Sep 2026 22:59:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C10F681CE7; Thu, 24 Sep 2026 12:59:38 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id nC6NX6pdpTML; Thu, 24 Sep 2026 12:59:37 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org A70D481BBD Authentication-Results: smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254777; b=bK3ftIT0f7Mn2ZdByi81dmk99/AoScAmaHFOoBr3xQdaEmrcv8810v44OMCW5/WuiVh3 bhUkGrmFnJGB+Vh/WtmWKFL1SieP1K1zHSAiTec8UMZAzO/a8WwbwLCTVb04/NQtyHMwC 7wSCnql3HdlHUrpCzvf6tW3zi3DKovg0N9fwWFrr9EkZqQSgcbqh8q61OavwIyuLqhPvN Uqv76rDWB1Bkh2rKEC2Vvoki9RTMgGi7uutCmGaPsF8RpPZZPV8DOeqc5A4I78gSnsJs8 lUCXG3MXa1jBikEnCL9c/GhIk2WdLdMq7O3lQv3g6E5J+ZAAaPiW2OpfzZe63n94+Pg== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254777; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=pQMFFCya3wmc2ap38hLSqFx15I+RY820Z4UXZaDfLT4=; b=ecrTiLhbeOW2dG7RkPrt0pmqTH3PglH4TPdZiSPeYFUnO07IE5h9XQwzSGCwOGuUN70u jZpJcSa6KmilmEbsWdh6+7g259o9b7WW8LppqeqOvmYbCJrpqZVlQq4i5XfpceTGr4cCn EzNbDWWtu8FiEjfEzgvRObOG38yTwPn73crbF+XXAEL7wAPEIqnEldW1Uo0x65S5MZ7tV XuluGE/acTxIxZZ38BO7R5OX58BsLCGFWu+nzFFyUTXW+Ra7ESP/Z7ZSC2fFOl+KtfzXM 493Sdg7OrqfC8nurUJWRuGFB7Fr41dQUlDPQ2fAWZsj9S80Xh2XFgCS6/5zjHSvISQA== ARC-Authentication-Results: i=2; smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254777; bh=pQMFFCya3wmc2ap38hLSqFx15I+RY820Z4UXZaDfLT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RpBU1aJ3CahXXzCzCCppG/OihyNNNT6Cn75MIvYxihjoonUdQ4Q8rY2esamTy+yGM SJKJVkCXBgOFf+164jviQNB4FTNfr5/cGAZesc4NH4gO6AycTIb/5AizPFPPEnkmUh 2r/5/g5qjVbyMBrL+FwluWyEkFPNwCAhOspeS914JGUauOxfevrHeZitdRM+m+KrjU RCeu/4Ge8T6ayEtU8B39tMpRgIPlgbFB8Ka/MkGdQWHuo57ha/ZWDijCnDSMZfLS/e 70uv6dEZ7H9ou4peqfpVo5m3RtYQFwI7KjEj7N6pSFJ4VcM58X7aF6fR48gt/Rr8/C vZZE3jOwKCPdg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id A70D481BBD; Thu, 24 Sep 2026 12:59:37 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id F0F581344 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EE99D60838 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5-8_BRUIKI56 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org CC2D160807 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254772; b=ijxVQy/5uZMnnSLV1gUQUiHlgSRK9nNavx8PSog0V+sMPU/x2wZV4c8Uiz5j6WLxnsWi M+iwd2NYx0V8hPoXvfhqF0mAgUnC9WqEn0s9CgBNQTeSxe5vT6YIDnPMaYj5SUwpekJoO qVMpYhS4DrnassOqMSovltQIhsOyAe0fO2XOBVqkJfQHB7UOKrZokSeTzi4r/BfxzMHYk LkZPiCCdZAyqgzVfQNR4sAYr7PNjM1yiZ28qrvEH0cWAr2T3StJR4aG2pKQWcfL22SUL7 RH1r9BLsEyDV92zRkbzGF4WkrZKBihSXbiKrbH/mBimI8Dd7Jo3MdLhfo9q+AWtpAjQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254772; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=pQMFFCya3wmc2ap38hLSqFx15I+RY820Z4UXZaDfLT4=; b=GFBj2rBv0TjPGZQbbJI5oPVP36XhVleYhryMzH58oAfGeuK6XC9odMrIIrH1z8YPvTba QkgTt4o1P2eFnvmeUByWhbli/L8/5mU9WDey3/dakEKrTM7JfByc6d3qaT80x4MregGaY O6atBTokz+A2e9fI8AuBPmu02jPiXDCPIU6IewaocjAShMSJBv88WHt2yVhgMYx7qtAuS LxZM1bzChO4Zwh+xyJiu+iEGKHgSeC86QPD03psEX0M1lPZcEU3KQWspuTUbpqGrq/ckn 2x23SdHsp4eNzKA9sO6VhoW9Kw6EK1ytOfVZdxp8RNEXCpKgJAAR+Nng9Mnh98ZFuOA== ARC-Authentication-Results: i=1; smtp3.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jyXTeKNr; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jyXTeKNr Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp3.osuosl.org (Postfix) with ESMTPS id CC2D160807 for ; Thu, 24 Sep 2026 12:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254772; x=1821790772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TFXPy66pLteuugCAv0UVm4p+uz1rFLrm6jJ5MqbLUyM=; b=jyXTeKNrG/ilSr5ZMeECEB52lNiop8pXL4Zl5gMrc29K9tw9CsvIL4Pm sL0++ibAHfXqV9dXDAASameMwpSyLBDmmHpXypj4Z3kyVgnp0fn8Q9vo2 eisAeBaeQ4pPjAfOU6ndmnfxI/xjzkNWcpi/CdT0oeMxvVi+ccib93fp+ kp0il3Ehv7BIvqf5Yys/oXmO/HJvvw+GjyO7KEpF7rxnpSsoit/unyQ97 nMkoS9jrHf+k8rsPSvvMC1CiSyPX2KxRoWV3WjxBPUr+vJ6LWWTAM6Bus UYetiCHU/tASVkhX4tx2VvDfaUcHCTgg94YP/Gm9dQ1DYwcrg2o4J6eY0 g==; X-CSE-ConnectionGUID: 0ZkwflVOQM2ClO4G7fgzuQ== X-CSE-MsgGUID: m6dlf6NvSR2YPcb5LEg8PA== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249228" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249228" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:22 -0700 X-CSE-ConnectionGUID: oxql0OkUTdKTW7bEU7miAw== X-CSE-MsgGUID: cla2MIzJT8GAta8CtV+IvQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934427" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:21 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 4/8] ice: Reject PTP access without a control PF Date: Thu, 24 Sep 2026 12:59:12 +0000 Message-ID: <20260924125916.2796499-5-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org The timesync register space is not accessible through a secondary NAC. ice_get_primary_hw() currently falls back to the caller's hardware when the control PF is absent, causing secondary PFs to access the wrong register space after the control PF is removed. Return NULL instead and propagate the missing control PF through PHC reads and timer setup paths. This leaves secondary PFs operational while PTP requests fail safely until a control PF is available again. Fixes: e2193f9f9ec9 ("ice: enable timesync operation on 2xNAC E825 devices") Signed-off-by: Sergey Temerkhanov Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/ice/ice.h | 9 +-- drivers/net/ethernet/intel/ice/ice_ptp.c | 71 ++++++++++++++----- drivers/net/ethernet/intel/ice/ice_ptp.h | 11 +-- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 23 +++++- .../net/ethernet/intel/ice/virt/virtchnl.c | 5 +- 5 files changed, 85 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 08b40626b876..c454f19a2cb2 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -1146,8 +1146,8 @@ static inline bool ice_pf_src_tmr_owned(struct ice_pf *pf) * while holding adapter->ctrl_pf_lock. * hw is embedded in struct ice_pf, so either mechanism protects its lifetime. * - * Return: A pointer to ice_hw structure with access to timesync - * register space. + * Return: A pointer to ice_hw structure with access to timesync register + * space, or NULL if the control PF is not available. */ static inline struct ice_hw *ice_get_primary_hw(struct ice_pf *pf) { @@ -1156,10 +1156,7 @@ static inline struct ice_hw *ice_get_primary_hw(struct ice_pf *pf) ctrl_pf = rcu_dereference_check(pf->adapter->ctrl_pf, lockdep_is_held(&pf->adapter->ctrl_pf_lock)); - if (!ctrl_pf) - return &pf->hw; - else - return &ctrl_pf->hw; + return ctrl_pf ? &ctrl_pf->hw : NULL; } /** diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 455e3af30abe..3ee29c0cd726 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -214,17 +214,23 @@ void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) * @pf: Board private structure * @sts: Optional parameter for holding a pair of system timestamps from * the system clock. Will be ignored if NULL is given. + * @time: Storage for the source clock time + * + * Return: 0 on success, negative error code otherwise. */ -u64 ice_ptp_read_src_clk_reg(struct ice_pf *pf, - struct ptp_system_timestamp *sts) +int ice_ptp_read_src_clk_reg(struct ice_pf *pf, + struct ptp_system_timestamp *sts, u64 *time) { struct ice_hw *hw = &pf->hw; u32 hi, lo, lo2; u8 tmr_idx; scoped_guard(rcu) { - if (!ice_is_primary(hw)) + if (!ice_is_primary(hw)) { hw = ice_get_primary_hw(pf); + if (!hw) + return -ENODEV; + } tmr_idx = ice_get_ptp_src_clock_index(hw); guard(spinlock)(&pf->adapter->ptp_gltsyn_time_lock); @@ -232,12 +238,12 @@ u64 ice_ptp_read_src_clk_reg(struct ice_pf *pf, ptp_read_system_prets(sts); if (hw->mac_type == ICE_MAC_E830) { - u64 clk_time = rd64(hw, E830_GLTSYN_TIME_L(tmr_idx)); + *time = rd64(hw, E830_GLTSYN_TIME_L(tmr_idx)); /* Read the system timestamp post PHC read */ ptp_read_system_postts(sts); - return clk_time; + return 0; } lo = rd32(hw, GLTSYN_TIME_L(tmr_idx)); @@ -260,7 +266,9 @@ u64 ice_ptp_read_src_clk_reg(struct ice_pf *pf, } - return ((u64)hi << 32) | lo; + *time = ((u64)hi << 32) | lo; + + return 0; } /** @@ -997,13 +1005,15 @@ static int ice_ptp_init_tx(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) * Return: * * 0 - OK, successfully updated * * -EAGAIN - PF was busy, need to reschedule the update + * * -ENODEV - no control PF owns the source clock register space + * * -EOPNOTSUPP - PTP support is not compiled in */ static int ice_ptp_update_cached_phctime(struct ice_pf *pf) { struct device *dev = ice_pf_to_dev(pf); unsigned long update_before; u64 systime; - int i; + int err, i; update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); if (pf->ptp.cached_phc_time && @@ -1016,11 +1026,22 @@ static int ice_ptp_update_cached_phctime(struct ice_pf *pf) } /* Read the current PHC time */ - systime = ice_ptp_read_src_clk_reg(pf, NULL); - - /* Update the cached PHC time stored in the PF structure */ - WRITE_ONCE(pf->ptp.cached_phc_time, systime); - WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); + err = ice_ptp_read_src_clk_reg(pf, NULL, &systime); + if (err) { + /* The source clock is gone, so the cache can no longer be + * refreshed. Publish zero instead of leaving the last good + * value behind: ice_ptp_get_rx_hwts() has no staleness check + * and would keep extending Rx timestamps against it. + * cached_phc_jiffies is deliberately left alone so that + * ice_ptp_extend_40b_ts() still discards Tx timestamps. + */ + systime = 0; + WRITE_ONCE(pf->ptp.cached_phc_time, 0); + } else { + /* Update the cached PHC time stored in the PF structure */ + WRITE_ONCE(pf->ptp.cached_phc_time, systime); + WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); + } if (test_and_set_bit(ICE_CFG_BUSY, pf->state)) return -EAGAIN; @@ -1043,7 +1064,7 @@ static int ice_ptp_update_cached_phctime(struct ice_pf *pf) } clear_bit(ICE_CFG_BUSY, pf->state); - return 0; + return err; } /** @@ -1073,8 +1094,8 @@ static void ice_ptp_reset_cached_phctime(struct ice_pf *pf) * properly reset them here. This could lead to reporting of * invalid timestamps, but there isn't much we can do. */ - dev_warn(dev, "%s: ICE_CFG_BUSY, unable to immediately update cached PHC time\n", - __func__); + dev_warn(dev, "%s: unable to immediately update cached PHC time, err %d\n", + __func__, err); /* Queue the work item to update the Rx rings when possible */ kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, @@ -1811,6 +1832,7 @@ static int ice_ptp_cfg_perout(struct ice_pf *pf, struct ptp_perout_request *rq, u64 clk, period, start, phase; struct ice_hw *hw = &pf->hw; int pin_desc_idx; + int err; pin_desc_idx = ice_ptp_find_pin_idx(pf, PTP_PF_PEROUT, rq->index); if (pin_desc_idx < 0) @@ -1849,7 +1871,10 @@ static int ice_ptp_cfg_perout(struct ice_pf *pf, struct ptp_perout_request *rq, * at the next multiple of period, maintaining phase at least 0.5 second * from now, so we have time to write it to HW. */ - clk = ice_ptp_read_src_clk_reg(pf, NULL) + NSEC_PER_MSEC * 500; + err = ice_ptp_read_src_clk_reg(pf, NULL, &clk); + if (err) + return err; + clk += NSEC_PER_MSEC * 500; if (rq->flags & PTP_PEROUT_PHASE || start <= clk - prop_delay_ns) start = div64_u64(clk + period - 1, period) * period + phase; @@ -1992,8 +2017,12 @@ ice_ptp_gettimex64(struct ptp_clock_info *info, struct timespec64 *ts, { struct ice_pf *pf = ptp_info_to_pf(info); u64 time_ns; + int err; + + err = ice_ptp_read_src_clk_reg(pf, sts, &time_ns); + if (err) + return err; - time_ns = ice_ptp_read_src_clk_reg(pf, sts); *ts = ns_to_timespec64(time_ns); return 0; } @@ -3041,9 +3070,13 @@ static void ice_ptp_periodic_work(struct kthread_work *work) ice_ptp_maybe_trigger_tx_interrupt(pf); - /* Run twice a second or reschedule if phc update failed */ + /* Run twice a second, or retry soon if another thread was busy + * updating the Rx rings. Other errors, such as a missing control PF, + * do not clear up on their own and must not turn the periodic worker + * into a busy loop. + */ kthread_queue_delayed_work(ptp->kworker, &ptp->work, - msecs_to_jiffies(err ? 10 : 500)); + msecs_to_jiffies(err == -EAGAIN ? 10 : 500)); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 8a341e3cba17..562822b106d5 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -331,8 +331,8 @@ void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx); void ice_ptp_process_ts(struct ice_pf *pf); irqreturn_t ice_ptp_ts_irq(struct ice_pf *pf); bool ice_ptp_tx_tstamps_pending(struct ice_pf *pf, bool in_irq); -u64 ice_ptp_read_src_clk_reg(struct ice_pf *pf, - struct ptp_system_timestamp *sts); +int ice_ptp_read_src_clk_reg(struct ice_pf *pf, + struct ptp_system_timestamp *sts, u64 *time); u64 ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc, const struct ice_pkt_ctx *pkt_ctx); @@ -384,10 +384,11 @@ ice_ptp_tx_tstamps_pending(struct ice_pf *pf, bool in_irq) return false; } -static inline u64 ice_ptp_read_src_clk_reg(struct ice_pf *pf, - struct ptp_system_timestamp *sts) +static inline int ice_ptp_read_src_clk_reg(struct ice_pf *pf, + struct ptp_system_timestamp *sts, + u64 *time) { - return 0; + return -EOPNOTSUPP; } static inline u64 diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c index 38e90a68ba78..a85aa8f99057 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c @@ -339,8 +339,11 @@ void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd) guard(rcu)(); - if (!ice_is_primary(hw)) + if (!ice_is_primary(hw)) { hw = ice_get_primary_hw(pf); + if (!hw) + return; + } wr32(hw, GLTSYN_CMD, cmd_val); } @@ -359,8 +362,11 @@ static void ice_ptp_exec_tmr_cmd(struct ice_hw *hw) guard(rcu)(); - if (!ice_is_primary(hw)) + if (!ice_is_primary(hw)) { hw = ice_get_primary_hw(pf); + if (!hw) + return; + } guard(spinlock)(&pf->adapter->ptp_gltsyn_time_lock); wr32(hw, GLTSYN_CMD_SYNC, SYNC_EXEC_CMD); @@ -2020,6 +2026,8 @@ static int ice_read_phy_and_phc_time_eth56g(struct ice_hw *hw, u8 port, guard(rcu)(); pri_hw = ice_get_primary_hw(pf); + if (!pri_hw) + return -ENODEV; zo = rd32(pri_hw, GLTSYN_SHTIME_0(tmr_idx)); lo = rd32(pri_hw, GLTSYN_SHTIME_L(tmr_idx)); @@ -2199,6 +2207,10 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port) */ rcu_read_lock(); pri_hw = ice_get_primary_hw(pf); + if (!pri_hw) { + rcu_read_unlock(); + return -ENODEV; + } lo = rd32(pri_hw, GLTSYN_INCVAL_L(tmr_idx)); hi = rd32(pri_hw, GLTSYN_INCVAL_H(tmr_idx)); @@ -5354,8 +5366,13 @@ bool ice_ptp_lock(struct ice_hw *hw) down_read(&pf->adapter->ctrl_pf_lock); - if (!ice_is_primary(hw)) + if (!ice_is_primary(hw)) { hw = ice_get_primary_hw(pf); + if (!hw) { + up_read(&pf->adapter->ctrl_pf_lock); + return false; + } + } #define MAX_TRIES 15 diff --git a/drivers/net/ethernet/intel/ice/virt/virtchnl.c b/drivers/net/ethernet/intel/ice/virt/virtchnl.c index ca8018e3dd42..66332d02c5ba 100644 --- a/drivers/net/ethernet/intel/ice/virt/virtchnl.c +++ b/drivers/net/ethernet/intel/ice/virt/virtchnl.c @@ -2485,7 +2485,10 @@ static int ice_vc_get_phc_time(struct ice_vf *vf) len = sizeof(*phc_time); - phc_time->time = ice_ptp_read_src_clk_reg(pf, NULL); + if (ice_ptp_read_src_clk_reg(pf, NULL, &phc_time->time)) { + v_ret = VIRTCHNL_STATUS_ERR_NOT_SUPPORTED; + len = 0; + } err: /* send the response back to the VF */ From patchwork Thu Sep 24 02:59:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310788 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=bmYTfeMj; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J+kshiA6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSY6dbvz1xyS for ; Thu, 24 Sep 2026 22:59:41 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9086B40CD6; Thu, 24 Sep 2026 12:59:40 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id x9PyHwbp5dOS; Thu, 24 Sep 2026 12:59:39 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp4.osuosl.org 9B6AB40CDC Authentication-Results: smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254779; b=XfxCglUcdpIy6ckls0mH8mEEyeIMcb/KP2YJ+MZCrVRqE94pe+d7QMNZOtkT54Wkkg7v tK0NdH3V4b6+y89GjEexyz6MLNPcJ4k51WF4qiDZgdb0bd1ar0Enr0/IR7C+eu7OYUXIB SZZ45JIzAdQvisjly35uCPOSwhm3sAgDEdATb/gkDxg+j4/5bSfCjNMKtbdWbg8DaveKd +RRwY8f76WMuTdMl2wl/NRXEgQNSm0apvX3G4Bs/MT9cxRMP50hnvxnT7tP9LZ13ejs/O k6XXiNqxgHdDegekSwP969t1hVdxQZiVbeXb3Ho5zmCs9omYiH9kZAbhN5JMmzQbF2A== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254779; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=NMJRkb5P21AHtDGDTdMDmbeEU2mqY4xrFAMSVB8Bw70=; b=tN4C9Rpc/WYTP2A2r43iF2MvQqE2cPS3Dj6bqpUUU854e9n7dAS1gznLw8inU0jN9ec8 Yni9WyQTtJNDcPUSijnKVnnDUlA7xkawy/vcRFz5ZTj/fF6p9adPVQv7ZnVyb0qWGYUmv e7r+gImBoAKx7zYslb+BmO+38izIC4LoCy3dDlpVqoNW862rrRDHTNb2XwkcWjeiAAAV8 zIUqEafya3FMj/n2hj4S1kDQB8GrY/O6j4YKgcJeoTUf8hvC9PA72LTNK+PslGcGzyOEP DbcH2WFDYaw0PUO2QfDHxVI8jbVsrRkr9MMV+NIMJfx3DVA4YniO2wyaBB6KUoNeBrg== ARC-Authentication-Results: i=2; smtp4.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254779; bh=NMJRkb5P21AHtDGDTdMDmbeEU2mqY4xrFAMSVB8Bw70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bmYTfeMj8kOqxZJPfi6SVeT38B2IO1u6SnfQUAFPxhPKFnU1WdB2GBgCR53apDgjN ovYS/UvIjW6+pa2H/yLx0QRHXAe0s16w4WenPZLmDoOgvrnMsHZLgxa6LZMfLjI0XX wjmq/AUW5GpDQ0oRkBg7m9kNJQMkk0VWFeKgZnQ9zaxYHJ7X0b0NUbQ51McxLdCLMo d805yDLRdssrSM1+GMY0S2VvgdoiVRgWD6vJyxgY/Ra8Oro7WSdm94t4hmPZOhk8eo grAV3my5RFEPUeJvOvfyk2zyvHmDTTtOUCspB56olMXYmAPtsU1uu0aGUwWDstZbY6 D4pLLNE7Sv0pg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 9B6AB40CDC; Thu, 24 Sep 2026 12:59:39 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id 60242194 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5266660807 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BtJJFoQlcs0x for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org 4261E6082D Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254772; b=SxT8mKYaMZi1eLMvKzE5MDheJySwoMeA0xDuGSqQRy7SHJnOC4N1d+Q8L+X9iRGQLZZr /ILWBpIzmT5OZSg7ICRYqTRzhYuHcpSozHaDYjDPpHVHp6M0t5xqsKTibxmPNNjKY/z0w gogHC8B9F7ItyBYCTuC+7xJwMAQS8JJyoMKG4a4hImt1Ul56PAeZCo0qoJ7Th/j7vgWK6 7k8Yj/YLW+kBTXRX3E84g/szlNjMiTOMsHrVZLhxAZFgYWHp3IjhH8EUHKFDkPymebfNi rgENsp0cGEu9syq7GaJFWNOTx6Q9MPxNVqphYASdxqbANAALaxpWtkwCWn1sphZBVkg== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254772; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=NMJRkb5P21AHtDGDTdMDmbeEU2mqY4xrFAMSVB8Bw70=; b=A6kGAGFg3SiXZWX1e4Lon8Vulsf3gPNqv6rsrXOm9pVYjlzcb9+0jYYthmpXZYwY0JLj 9u2RXF1+j0mo38IocoaN72hY2cu4tNEw4t+kP63z94enJyy3WwvMXQkKdVHs6Z11SO5To OBHhZP1YdFrRYbPceZr8s2efXOvRheRPAe4XNJl686KpUU7I4kVhktHne6E54k+MEU+e9 +iaKcc69FxL5jo+cAeuW2YbzvQvzYQrglbXdoQrPKhUywyJDGwBoICREWBaYYxHfDyB5B R6/J3dFVNna8rzUzgvJ8JulfbEOgi5go28RO/Y5bi9lve9P7242P410s2VVRZjblGCg== ARC-Authentication-Results: i=1; smtp3.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J+kshiA6; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J+kshiA6 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4261E6082D for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254772; x=1821790772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aaf1m91xnzH813tnvwtfaIyDWRoM2cZnDJhUGIqF7gc=; b=J+kshiA6h5l/TlJl39XeSg5oSYgSY9eeE0Tj/7VqE7nwx258qYdRMB2C AqSbblWEqvXsE16YJPhydbTzqkUvjVFN1KhRSEW77K/4RYGk+GWg1vnct HdbgDki3FoyjLTYhfWiKzROMWiGHv3aT3PtLqehMV2orvnABd35Hwne4c adTAJO4y3i1sO3+H7Z1wzx2583WUGItJLWrJ8HqgnvU6QXGoNroivVcXZ Z+Y0FlG6qFGC9F1PPSbkx/8NjlachyJIq2cn6KZ4esyS536jHP2oluABD vy2UHEo2jwb1hPQa5szoVPiKsJ1rfLfWxY3t1Dorer7uq+zx9vlerNAoJ A==; X-CSE-ConnectionGUID: IK/m/ZCgSMSVaf6MtQe2sQ== X-CSE-MsgGUID: TYKeHRMBRDCXmj3cVyfldA== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249236" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249236" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:24 -0700 X-CSE-ConnectionGUID: Kstyg882R7m8s9+Ax42aHA== X-CSE-MsgGUID: ZQ29WJM5QrKjOd03Hq5+gg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934428" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:23 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 5/8] ice: Clear the control PF pointer when the control PF is removed Date: Thu, 24 Sep 2026 12:59:13 +0000 Message-ID: <20260924125916.2796499-6-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Zero adapter->ctrl_pf when the PF owning it is removed and wait for pre-existing RCU readers before its storage can be released. Without this the pointer outlives the control PF, so sibling PFs keep dereferencing it after it has been torn down. The preceding patches make this safe to do: readers already resolve the pointer once per critical section, and the PTP paths already reject a missing control PF instead of falling back to the caller's own register space. Fixes: e2193f9f9ec9 ("ice: enable timesync operation on 2xNAC E825 devices") Fixes: e800654e85b5 ("ice: Use ice_adapter for PTP shared data instead of auxdev") Reported-by: Frederick Lawler Closes: https://lore.kernel.org/all/aIKWoZzEPoa1omlw@CMGLRV3/ Signed-off-by: Sergey Temerkhanov Reviewed-by: Arkadiusz Kubalewski Reviewed-by: Aleksandr Loktionov Tested-by: Frederick Lawler --- drivers/net/ethernet/intel/ice/ice_ptp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 3ee29c0cd726..3ed37bbae161 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -3300,6 +3300,20 @@ static void ice_ptp_setup_adapter(struct ice_pf *pf) rcu_assign_pointer(pf->adapter->ctrl_pf, pf); } +static void ice_ptp_cleanup_adapter(struct ice_pf *pf) +{ + guard(rwsem_write)(&pf->adapter->ctrl_pf_lock); + + /* Zero out adapter->ctrl_pf pointer when the ctrl_pf itself + * is being removed to prevent any secondary PFs from accessing + * it after it is deleted. + */ + if (ice_get_ctrl_pf(pf) == pf) { + rcu_assign_pointer(pf->adapter->ctrl_pf, NULL); + synchronize_rcu(); + } +} + static int ice_ptp_setup_pf(struct ice_pf *pf) { struct ice_ptp *ptp = &pf->ptp; @@ -3656,6 +3670,7 @@ void ice_ptp_init(struct ice_pf *pf) mutex_destroy(&ptp->port.ps_lock); err_exit: + ice_ptp_cleanup_adapter(pf); /* If we registered a PTP clock, release it */ if (pf->ptp.clock) { ptp_clock_unregister(ptp->clock); @@ -3683,6 +3698,7 @@ void ice_ptp_release(struct ice_pf *pf) if (pf->ptp.state != ICE_PTP_READY) { mutex_destroy(&pf->ptp.port.ps_lock); ice_ptp_cleanup_pf(pf); + ice_ptp_cleanup_adapter(pf); if (pf->ptp.clock) { ptp_clock_unregister(pf->ptp.clock); pf->ptp.clock = NULL; @@ -3697,6 +3713,8 @@ void ice_ptp_release(struct ice_pf *pf) ice_ptp_cleanup_pf(pf); + ice_ptp_cleanup_adapter(pf); + ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); ice_ptp_disable_all_extts(pf); From patchwork Thu Sep 24 02:59:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310787 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=03xnJDVd; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=muY0Uw9e; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSX4bX5z1y1K for ; Thu, 24 Sep 2026 22:59:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4A1E6819D5; Thu, 24 Sep 2026 12:59:39 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id DrEBJaNj8HMq; Thu, 24 Sep 2026 12:59:38 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 96927819F3 Authentication-Results: smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254778; b=XCQJRyzgmfxFebrJvxo738S6NomFpAmusQLmdHrqk1/ZN8JU37vnxz4zuOP71kL8mmFb b1Lc8bupagImqKfykw+Ja/LqYyu5QUevS8UNQXWjTZrB3hLX9QbxgRqfncCs5aSEy74dD te/P5ZYHBNYGnEmMh9u8D0EFur/ZTg54sW3ArgZ6skBztrX+T7XDavan0RvBtg6LPScml YNzRJGAgPA7y/6BLILh1gOmaTzRLBGlbMwIRQ35rI+z/b8fNPxVbBFdHW1gRl01p1KEC0 qPJFwD33Gpgy0dozn3EpaQdGGwVgcpF/cwWIOgxQ3g2rDF6+H8gEDoOnXyW8WadMVIw== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254778; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=uNMFT2QCDjVlZfJwuojXDQ13ilQUN12wpTKVfCqB+aM=; b=D+HDCowNk7M3RCITn0KFhzE+qrXfZB/Deqmc10jFdSaaK6A5PBa6KYYO3lULCTGV8+W5 jUZg+BwNkjXIYTsyTACTPe2Qprmyv42kQMUx5YF7S47Ui8HHjpO7LAFdz4qolj57pxnzC xInckhv1U2nETdWT9tE2FFB6l534klJnqVfGgOlJg8L5XHlhKRSMbXZ/p1w/ObTmXWskj p8nlPjVxekHZRH1vu/xraE6UEozkLEwXuTX5b4MvevQIQPc8XRiNurFLYqkkFgLzk9pTC 1MvQIaraI/VNvyfZmSDc14jnPGURS7u+HwvEoVRaZsf2WwtgVksbfWaBZkfkZPZGHsA== ARC-Authentication-Results: i=2; smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254778; bh=uNMFT2QCDjVlZfJwuojXDQ13ilQUN12wpTKVfCqB+aM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=03xnJDVdcE4B8kyfCLpeSMnFqRTZ8jCg3iNeXqH4bTOzjug+1mBFKFuvN4DQ3gu7i sN1hpp7nMDKsTPq2mXyRVsk2pPcvzgaYRrHKjDlBJkrgM7s+PL4mEa/IYG8rFn+kDb X/DURyFmMv0sUxQNtT+eowmz9i0vkAITyrjF+eCakh8qdn47pduXzp+Pv10c8bDMaQ C87BEDQlsGzFfDih2UFCPJlxwzaMnMSvV8Asht9eMdXJnmmYceL7fuYch6cAEFFhkY Nf8qkkwZgA+7BUq/vWA+o3sW94pp83hkvVOF9Xw6TYZ5lJwjVgWbS1IBP7tB2tM8P+ 3dsydDYw9QLKw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 96927819F3; Thu, 24 Sep 2026 12:59:38 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id 14BEF1F41 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0E530400FB for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VLsXlhB9kFib for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp2.osuosl.org 45B9640456 Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254772; b=VUENUiMd0rTu+U80DBkrVh1CoeujPUwpi/J2HwNITTJ+wUGBs67Zcos89OLy8Mb/74r0 wA05H2lIQ7Ab5zBoxm2lYxRvYC4aPVksoJ5i3E/MIugkJCGvClvM3Tu39sEO2ihXsFDB2 cThaxzqhBsIB46YXjssKmwHg5L7mqKPGQ2U7OMzfxirwg8vhzzNVzx7cplerpVNtQcTsF NYURLlN6vHhQsy5AmU/+eDV2SZHGI+PZPpEA541QMh2vxhI5xjANh1o4NyBESnRsa7RBF qnYBhT4uzjjIe6UWM09ounuHzxEJSkAW/RGToPMjaCbZTxV1Q/3EuAiPXBk2NyGuJ1g== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254772; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=uNMFT2QCDjVlZfJwuojXDQ13ilQUN12wpTKVfCqB+aM=; b=YFvn7gu6WAKIqybOthOHeKt3w6BgZGtv5v9N+8GYn6I5uqR1CzwKTFjO6DYxkadoqH3c IC7ho+zSX3tz2ta/keoJXD27vrIsoz8ubsBU+mWTAUAaTG6FfR6/F99EPGof3l8/XRXoV v6yNj2HmL/zX2lvO0SI/lghudJhMlx1WwL62f2znq3r862nqVaKAy5cn2PQ+4qwc9idMM XeYPYKFaZST55/8g2dT9A5pvTU734u298T7apGjr4D8+XblP2lA6xcKbH2w9JpBiHxdf4 8w1SuN5JlCPxsovGE9nJvFSALM4s2s1i8x0yI8meCgpNdIwYI9+zAcs8Jh+2gwAWA2A== ARC-Authentication-Results: i=1; smtp2.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=muY0Uw9e; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=muY0Uw9e Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp2.osuosl.org (Postfix) with ESMTPS id 45B9640456 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254772; x=1821790772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0b3wewW4J9me+EBD22mhqtMxIvwOlQSGeFmNhvtYCyc=; b=muY0Uw9eu5AjeTglwRiaILEMYakoKCRQi8p2fZ3s6sYYeKPZbOysO/PK pXaHhOrRwS/4qbCmgGTfV9c7Y19cZtkzn2ysiNWcs9NIQXLTtTYfr5zpE Se4tAfIT2373Bja5eBWvxiSHAEwmfS7rtNCO1tPJmhG1UYlF1ElerkXdw ODFSb9O+sbDhXkUr+v3TM1Sk3nx7iuzyK1GOmGpbnKyZhA00hcplZc8ie h90fEeUl8JanAwz7SL6YsMfPSPSR5HbLa6cQlB/JOkZax/OQjfeyWY6lU dpHb2IP8Qt9DD8yQuSQ0o4ifPTLyXm8OCxO7bmIrFzRaHBwUutvx7xen5 w==; X-CSE-ConnectionGUID: mZgV4GtUR5qQMePXCjK4IA== X-CSE-MsgGUID: cx6ENbGLRB+TKx/wE3mzOQ== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249242" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249242" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:24 -0700 X-CSE-ConnectionGUID: gXqXcLCPTLKAoOkqsR84Aw== X-CSE-MsgGUID: AxK0IT0xRgOeOsUpOT+SRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934430" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:24 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 6/8] ice: Document control PF lock ordering Date: Thu, 24 Sep 2026 12:59:14 +0000 Message-ID: <20260924125916.2796499-7-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Document adapter->ctrl_pf_lock as the outer lifetime lock for TX clock state and PTP hardware semaphore operations. This makes the existing ordering constraints visible to future callers and helps avoid nesting the rwsem below a DPLL lock. Signed-off-by: Sergey Temerkhanov Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/ice/ice_dpll.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.h b/drivers/net/ethernet/intel/ice/ice_dpll.h index f7e6680d124c..67f2fc6e79e4 100644 --- a/drivers/net/ethernet/intel/ice/ice_dpll.h +++ b/drivers/net/ethernet/intel/ice/ice_dpll.h @@ -156,10 +156,21 @@ struct ice_dpll { * Locking: * Acquisition order (top to bottom): * - * txclk_notify_rwsem (read) - * -> pf->dplls.lock - * -> ctrl_pf->dplls.lock + * adapter->ctrl_pf_lock (read) + * -> txclk_notify_rwsem (read) + * -> pf->dplls.lock + * -> ctrl_pf->dplls.lock * + * PTP hardware semaphore path: + * + * ptp_port->ps_lock + * -> adapter->ctrl_pf_lock (read) + * -> PFTSYN_SEM + * + * - ice_ptp_port_phy_restart() takes @ps_lock before reaching + * ice_ptp_lock() via ice_start_phy_timer_eth56g() or + * ice_start_phy_timer_e82x(), so ctrl_pf_lock is not the outermost + * lock on that path. Never take @ps_lock with ctrl_pf_lock held. * - @lock serializes all DPLL state mutations on this PF. When the * controlling PF's lock must also be taken (e.g. updating the shared * tx_refclks usage map), acquire pf->dplls.lock first, then From patchwork Thu Sep 24 02:59:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=QsFpifpg; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YGdY0InY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSb4Kw9z1xyS for ; Thu, 24 Sep 2026 22:59:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 413D681BBD; Thu, 24 Sep 2026 12:59:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id U6tCCp-PUJF1; Thu, 24 Sep 2026 12:59:41 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 6D29781CD0 Authentication-Results: smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254781; b=FRSnG2rcbWeJAlkzIQNL5jZnAFTlysGLhVRbxDbQs9wpeZqOAioOwEZ7rw2XLoVzyoQ7 ur+9H8qznVQTnWLG6BN3UjB8FLN/QLggLveO6uRxZNKYdpJOveKJMVw3WK4qBpneAEIbu +LYyvbiE8GvjYRupsa6f2rUSpOAVyqoq6yLLs5CSTzzTXFcsUq/RtQO77RlNjlfM3b9ML un09OPJt0HzlZixfBP/qle/hA1sYkLj7nIs+58DGR7/Lz9sEAJE7pQ9ByvWUYoH54Orl8 JJyDdPAHUm+APzo4meF6rV03P4j/O50F3lKSPm1zxFW2JFm/+LXKh6FBOjNOxgi557A== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254781; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=Q/0F1lRA0KxFHCz6ZH4xA5oaartOM54tEKJ6UNKgiQU=; b=KKdbfRNzoVraGSRktz6kd4iO/DgJQTSuVUQ+QejqGlFGZliP7gHhWyJqUvOlsclrAu1z oYLg2bjvPwvNVoF6q+bD6MUbjCoLb2laIXXL3lR7trz5VT6L09LSfYtyHrlYM3l6TyWPC WV+CpxOGn4DP5eAXBmIL2D+jG9wj3AiVafXmcJajqAAIzkvGTJp68RFoUpnIbdVnh0dsI FWK/AVDsTQu60pm1IkRcdUXCpbLt6aDN6+OgulJHrYZC/UmKzV6dYLqWvV/0lj7Vbn08o gv7ekBdOpgD3W4d3diPBquKrc7lnKI8Lwxci8ImQ3Qb816jwOD18fXjutPX0mY64zZA== ARC-Authentication-Results: i=2; smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254781; bh=Q/0F1lRA0KxFHCz6ZH4xA5oaartOM54tEKJ6UNKgiQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QsFpifpgsMk+93o59JKiaxCtXFTeEkaMMdtrybfbOFnlOh5/X4k4+t1QgDD0HdyAl mvW9/lzelz3zp7Q7q7pJpN1D47w2+v8KG+PCixiKBnIPJZm1FP9bNw2PEPj1DiiFjF 1dF4JgNcAxMoh/gm+raSjcZg39iuZXG84IETeSjzTZOieeJuUr7u+tNwFd0tA40yxJ /f4JYRKell5ZO6ubluFfCE8uvA78CNXIzvSNs+1mEl0VlPf0YrxxhkhU1UH33GYghT OkW+xc8MeVqyHyYsjOccqHVnJJ2npjBmam9P1r+YuTWZcvqSPtoGJAEqB83G3kSwC3 /C+Kwd0xIqKWQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 6D29781CD0; Thu, 24 Sep 2026 12:59:41 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id 839A11F41 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 74B5260807 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OZFFglqE1BKT for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org A638960824 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254772; b=eLTdM+ZJ2J4ZSMxOaF98T3dMUata/Ec6EuGyQm024ZQiCSFCT7KRl6vGsLHwN7DV9ii7 lYuQblML+EuZHmt9SQOK9i52O4NYFy9IU32iuL+7PdYu0ob/WNHm4UZ9qKKhJE9m2JsCL eVP9rTd1X6TSX9jho8NLcT+uSxHB3m3A82Rdhbk8rhbzs7sB8r+euXqeFpoaQJvaTdett WEgYsJiSOosmm1CMVdk5Hiy5DSugm634SiCDxdnXYzQnEfIeOEqoVx2Y9GAd9A82r8Juu zES3WKmVs3szo/IfV44B5GziFMvNR7YwAxxj82m/Y4w/1a8hLH6vvMSuM50vpa8Kb6w== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254772; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Q/0F1lRA0KxFHCz6ZH4xA5oaartOM54tEKJ6UNKgiQU=; b=Dlaw3/C0eKc5k01BS2fHSUlrTQFOJbZ1TG+GVoh5HJYndeIkZ0D03vCm2IFWRJgd+cTt Jaw+a4R6uvKkX1Md2HRXWEgOKnHgpjItN4JZEA4ZPXjVGPZtkGsqKdWRjji6TnVtXrwdB siYayuAZ6odm98HYg9eT/WR/cqcD5YKywJEXTQaIKJlcUIL7nYWAUtSZ5w9T3s39UL+wM 3McaLaOql5JCH6jyUvf95wuZeQWyjCXy0xRQnGGNpJnzw57Az3ef6ylMc9e3UcBqaqJ53 1GV/oCwZ+k+bAXZXCRtZ7rLugX7mj5/hsABgVEdkQhBM3bVLUT8rX6qPfVxBeH5VXIQ== ARC-Authentication-Results: i=1; smtp3.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YGdY0InY; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YGdY0InY Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp3.osuosl.org (Postfix) with ESMTPS id A638960824 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254773; x=1821790773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XTikmKf6gQDrTZu/kQxT5155ydRKPagkSJygHGDmZuo=; b=YGdY0InYjpEveD2kG0RQbvfLec54dx8UNLIBFGCDc9Agls/xmtmXoleM bKPlT5h9T4YtyVF0NXpm9NhPV17R8YpZX0nlYaN/sreCZTObWmOpegldI HWXuui3hMGXgAU7QYqa5Fj6VyffM2kICK30m+3Pxfw0b5+oaIPbrWq/cm GEVRW8Y6yQNGiNwdbw3PLgEjX6eKGY3yzvUbdpeRKEUOZFi0+3tHlw5Wr ESDFqyuMI93AE4np+CyyIOVcBAd/6M6gmcxJXMelre0mleJAORrWGsTGQ qNU8JBnHgd42oigpkkWo4hTTMCzKQ+U48fZGZURPT1a7nWFD6q9nou18r w==; X-CSE-ConnectionGUID: JyKTAx4WTJCLjiP3tlAkSw== X-CSE-MsgGUID: HiWs7tBlT026pgCetmXsSQ== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249251" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249251" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:26 -0700 X-CSE-ConnectionGUID: pb/ZDq2ZT26kSpfoFx9lKg== X-CSE-MsgGUID: /zWNdHnIQeyw/fwM9d1iCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934432" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:25 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 7/8] ice: Annotate PTP control PF lock handoff Date: Thu, 24 Sep 2026 12:59:15 +0000 Message-ID: <20260924125916.2796499-8-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org ice_ptp_lock() conditionally retains ctrl_pf_lock for read when it successfully acquires the hardware semaphore. The matching unlock occurs in ice_ptp_unlock(). Describe this cross-function handoff with context analysis annotations so static analysis can verify callers. Signed-off-by: Sergey Temerkhanov Reviewed-by: Przemyslaw Korba --- drivers/net/ethernet/intel/ice/ice.h | 12 ++++++++++ drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 26 +++++++++++++-------- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 6 +++-- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index c454f19a2cb2..8b7891ac25b0 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -1179,4 +1179,16 @@ static inline struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf) rcu_dereference_check(pf->adapter->ctrl_pf, lockdep_is_held(&pf->adapter->ctrl_pf_lock)); } + +/* container_of() expands to a statement expression, which clang cannot parse + * inside a context analysis attribute argument, so open-code the cast here. + */ +#define ice_hw_ctrl_pf_lock(_hw) \ + (&((struct ice_pf *)((void *)(_hw) - \ + offsetof(struct ice_pf, hw)))->adapter->ctrl_pf_lock) + +bool ice_ptp_lock(struct ice_hw *hw) + __cond_acquires_shared(true, ice_hw_ctrl_pf_lock(hw)); +void ice_ptp_unlock(struct ice_hw *hw) + __releases_shared(ice_hw_ctrl_pf_lock(hw)); #endif /* _ICE_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c index a85aa8f99057..eb7fdd000cf2 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c @@ -5361,15 +5361,16 @@ static void ice_ptp_init_phy_e830(struct ice_ptp_hw *ptp) bool ice_ptp_lock(struct ice_hw *hw) { struct ice_pf *pf = container_of(hw, struct ice_pf, hw); + struct ice_hw *pri_hw = hw; u32 hw_lock; int i; - down_read(&pf->adapter->ctrl_pf_lock); + down_read(ice_hw_ctrl_pf_lock(hw)); if (!ice_is_primary(hw)) { - hw = ice_get_primary_hw(pf); - if (!hw) { - up_read(&pf->adapter->ctrl_pf_lock); + pri_hw = ice_get_primary_hw(pf); + if (!pri_hw) { + up_read(ice_hw_ctrl_pf_lock(hw)); return false; } } @@ -5377,7 +5378,8 @@ bool ice_ptp_lock(struct ice_hw *hw) #define MAX_TRIES 15 for (i = 0; i < MAX_TRIES; i++) { - hw_lock = rd32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id)); + hw_lock = rd32(pri_hw, + PFTSYN_SEM + (PFTSYN_SEM_BYTES * pri_hw->pf_id)); hw_lock = hw_lock & PFTSYN_SEM_BUSY_M; if (hw_lock) { /* Somebody is holding the lock */ @@ -5389,7 +5391,7 @@ bool ice_ptp_lock(struct ice_hw *hw) } if (hw_lock) - up_read(&pf->adapter->ctrl_pf_lock); + up_read(ice_hw_ctrl_pf_lock(hw)); return !hw_lock; } @@ -5404,14 +5406,18 @@ bool ice_ptp_lock(struct ice_hw *hw) void ice_ptp_unlock(struct ice_hw *hw) { struct ice_pf *pf = container_of(hw, struct ice_pf, hw); + struct ice_hw *pri_hw = hw; - lockdep_assert_held(&pf->adapter->ctrl_pf_lock); + lockdep_assert_held(ice_hw_ctrl_pf_lock(hw)); + /* ctrl_pf cannot be cleared while ctrl_pf_lock is held for read, so a + * successful ice_ptp_lock() guarantees a primary hw is still there. + */ if (!ice_is_primary(hw)) - hw = ice_get_primary_hw(pf); + pri_hw = ice_get_primary_hw(pf); - wr32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id), 0); - up_read(&pf->adapter->ctrl_pf_lock); + wr32(pri_hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * pri_hw->pf_id), 0); + up_read(ice_hw_ctrl_pf_lock(hw)); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h index 16b1988e993d..ce8eb0672e71 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h @@ -293,8 +293,10 @@ extern const struct ice_vernier_info_e82x e822_vernier[NUM_ICE_PTP_LNK_SPD]; /* Device agnostic functions */ u8 ice_get_ptp_src_clock_index(struct ice_hw *hw); -bool ice_ptp_lock(struct ice_hw *hw); -void ice_ptp_unlock(struct ice_hw *hw); +/* ice_ptp_lock()/ice_ptp_unlock() are declared in ice.h, where struct ice_pf + * and struct ice_adapter are complete and ice_hw_ctrl_pf_lock() can be used + * in their context analysis annotations. + */ void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd); int ice_ptp_init_time(struct ice_hw *hw, u64 time); int ice_ptp_write_incval(struct ice_hw *hw, u64 incval); From patchwork Thu Sep 24 02:59:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2310789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=8BGMtl8D; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=m5F+KpdF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrDSZ3w75z1y1K for ; Thu, 24 Sep 2026 22:59:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2ED7981B8A; Thu, 24 Sep 2026 12:59:41 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id jOpkOwRVUu99; Thu, 24 Sep 2026 12:59:40 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 88BEB81BBD Authentication-Results: smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=pass; t=1790254780; b=hXGCwaBiKGFQQnudCDbKBMmjswUNqhZCnlV3aC7QcNApbMZjF6cCZW4jwLQFBlViBK/a +doCoPD/QuxkuhfWCjf3vcxT0aCzGTVk5eZLGG7BF+3sWOAjFxWSUq+ujlxh+Zsat287y j1KfMqbPkea6xYzXa+neHcTBBM5GSYnDqkjOuaz35Gra9nrAerkmPAPU2jYbuzimPw4FE kbER/4rh+HtgTYDLp/5HsXp2wd2yfSdltHgXuM9HosFOg2pnpEyHgWt3FdZANXCToP2Z4 Ctt37I7dWCByPB9ICXNOSkmn/whVifnsA0sbP4p/HGY6UlTVzTlzA5ao8fAhgBPbVJg== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254780; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV: X-IronPort-AV:Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1: X-IronPort-AV:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=S0HmbmvUnyNABrS5gZybRJ8qTHLPFlxZP//naxo6VYA=; b=LRW272ZQj94TxOoLE3X+SRnbKhp2AbN0xvMtlF2TfZzIX7x2ceiJovLSxuRJT4lUAo2L nC35QpPNgtDtoEAaHcRZk1jXzVkxAKe06jwDBgb28tSVxD0aIQViRfLrLTbDWFZOzUuxG vfl7eqZYcQextJYD6hwnSCzVUIJAc6p/pPl/pCIdxAiNa91Vn+J/Eu51vz0FLkfCY3sRW R0gGYiMwCAFIuCBq+3TvehXpTzrbcyv/PTQ6BOvwXSNgE/yZfzIjR25A/rcLsEJ7Zdfoz IkxAPlIT4tJ0zRPewKXU3iZeFavi4NNGtnXMPnXVhx04btcotrDQPMuCuJUIKdRei6A== ARC-Authentication-Results: i=2; smtp1.osuosl.org; arc=pass header.oldest-pass=0 smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1790254780; bh=S0HmbmvUnyNABrS5gZybRJ8qTHLPFlxZP//naxo6VYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=8BGMtl8DMG8LrbTFrSKVrDb2S0S4SG5P1xwGQyga1uJ9UlzoV2t5UtUR+sCa5UUOr 4MEcF3v3D0HkYb6MGPVn9SzzkOji/zeogFfBMmxzqzVwzsaxx0XVCiDYQSukYvEasE iBWQh3eTWrfDyypH4QY/xpoxeLsJsUTT80hvDTlmdCo2i6L+o7H4IoPi/1fnOhrJ4m FIxPwgSHV4d3z9FPopMS0sY3EmkX0EDHQbFNtl4YYyZz+XqtN3QQENtoeOP0xjoCEc x7Kwb0N7sAaSKDPBFoi8VsIFsVK+1XchctESJYcgg5llSNti9kgYBGu6ziaKWBCTDs 941J4EPRyhFXQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 88BEB81BBD; Thu, 24 Sep 2026 12:59:40 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id 7A85C194 for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 60E89400FB for ; Thu, 24 Sep 2026 12:59:33 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id MYrsYbqnWcYV for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp2.osuosl.org AC23D40470 Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790254772; b=PwFrjD8k4W6cVKm1WZegOpuuigFV8Vg9A7TRdIXpnwObxZunL8HGkPeQegh5ndlc0zMv dn/+6ctSM5HEbD/3aSM8UCIQKtgc0SXXa1o+TGhReVuKJT5im3WwZ5TVWMF8qquXrCxw6 fk3Ty7wwl0k5PiCwLnOZytdHGIXXb61TtLkuWtQTDUx3Xiw+679kH/rbvm34VOmA37C3W oeZrcCgyidnhMXlIjwY4OVHWZWhX2nQcRZrkveb+keVDUpbc6xkPuJhubGzQcLVUoFHEQ uEGoJcOueEnuhIR4PdvarQ8sqf+O/cywQGsU2yU3Y3Y0hnUh1911B8QO0xPKk/c92dA== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790254772; h=Received-SPF:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=S0HmbmvUnyNABrS5gZybRJ8qTHLPFlxZP//naxo6VYA=; b=dSfO2HcWeRkKclCChB/X2bgn+kvL0TGJlZvBE1qwWQt+bQuNWPsa1zOiO67tQT48IQcY 2tg/ZLKD8Yu6oFqju0vQPFCLz4M/9yu2RLTtu2zplq1zBD3E5Gwee6L7OMwEqeoauEZRr AatnwJX0O8oM4S8pN46qo3Pp5w4jcT8KeeYbC5MIidHSYdZk8CMmGbiQgmTZLQ4mJPSwb OP3wxJoaey+P0zd6arJ7bXxdDXEJu5F2idPWWn9UmkK2+ZkBWT6amKWqGSmRwJ7CgL3Nx rVMgXV366usboT1hU4QyugNleHoXsXsJF1xFRdrpyFXPF/0QOTs0JCE8ZNCDHeZj6nA== ARC-Authentication-Results: i=1; smtp2.osuosl.org; dmarc=pass header.from=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=m5F+KpdF; arc=none smtp.remote-ip=198.175.65.16 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.16; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=m5F+KpdF Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by smtp2.osuosl.org (Postfix) with ESMTPS id AC23D40470 for ; Thu, 24 Sep 2026 12:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790254773; x=1821790773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mKsIOdT7NnHNwx01DI9VzOebkFr0BP1VEviARtH2q/E=; b=m5F+KpdFTzvO1hN2Lggoo8OxUcUKyTpwyOW5WAyTu+fELkuG/JzIypcs Rl0n3jlXX8pnsxbWRX1Rmhm2ZzQtoygknSsAvI8FQMJ+YI1AQHmdDu+qv tuG1pIqGUt+iUij1UNdtwnZlfCfStwEhvUszIgjUVfdANWVztKVpRITQd GrSCq1AY0fp82KeiNrkD+70o96GSgN5HtAuFgGb0bqAmS3fpapFwFuCb6 pVoUylBOoj15H4D6BbBerYfo9msZpYG6aHVTZYsMqsfr0iXXG7V6X23rA q8o28LSTm+Ku0CKv6Y+gMNqBoG//bUPqKXusfH8xTs8Gnuadetm+B6GdE w==; X-CSE-ConnectionGUID: vIJJe4feSn+qjnm6r26FDw== X-CSE-MsgGUID: aoMBKAT8RDmeNErclXpSag== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90249257" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90249257" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 05:59:26 -0700 X-CSE-ConnectionGUID: TpJN7cXJRo2WmkSjOOVbaw== X-CSE-MsgGUID: bSiv6btbScuyDZd45+odbQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="311934433" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by orviesa001.jf.intel.com with ESMTP; 24 Sep 2026 05:59:26 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v5 8/8] ice: Release control PF lock before RCU wait Date: Thu, 24 Sep 2026 12:59:16 +0000 Message-ID: <20260924125916.2796499-9-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> References: <20260924125916.2796499-1-sergey.temerkhanov@intel.com> MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Clear ctrl_pf while holding ctrl_pf_lock for write, but release the rwsem before waiting for pre-existing RCU readers. The published NULL already prevents new readers from acquiring the retiring PF, so holding the writer lock through synchronize_rcu() only stalls sleepable users. Signed-off-by: Sergey Temerkhanov Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/ice/ice_ptp.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 3ed37bbae161..24d4ab2197c3 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -3302,16 +3302,21 @@ static void ice_ptp_setup_adapter(struct ice_pf *pf) static void ice_ptp_cleanup_adapter(struct ice_pf *pf) { - guard(rwsem_write)(&pf->adapter->ctrl_pf_lock); + bool synchronize = false; - /* Zero out adapter->ctrl_pf pointer when the ctrl_pf itself - * is being removed to prevent any secondary PFs from accessing - * it after it is deleted. - */ - if (ice_get_ctrl_pf(pf) == pf) { - rcu_assign_pointer(pf->adapter->ctrl_pf, NULL); - synchronize_rcu(); + scoped_guard(rwsem_write, &pf->adapter->ctrl_pf_lock) { + /* Zero out adapter->ctrl_pf pointer when the ctrl_pf itself + * is being removed to prevent any secondary PFs from accessing + * it after it is deleted. + */ + if (ice_get_ctrl_pf(pf) == pf) { + rcu_assign_pointer(pf->adapter->ctrl_pf, NULL); + synchronize = true; + } } + + if (synchronize) + synchronize_rcu(); } static int ice_ptp_setup_pf(struct ice_pf *pf)