From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E1B0CAC5BB for ; Wed, 8 Oct 2025 13:39:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1FA028077E; Wed, 8 Oct 2025 13:39:25 +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 rLurpRVvkx_J; Wed, 8 Oct 2025 13:39:19 +0000 (UTC) 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-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B2D2D813D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1759930759; bh=WbFuK/4oiB1Zs+o79HnjX8bWNB1wUj6a043KWopg/Rk=; h=Date:To:Cc:References:From:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZXXnqJhPnr1G8ZCt0sM4SiUTtYXA4YlJsA28KG64j75ZnplW55a0r4IQHBVKjW0To shyeMtZ8ie6vqNxOeebgwVBB3x3heqeIlRYQto6fKD9c+TmyHe/5TeKdn1MCMY64K4 IVW96GCfxAkpHqY8I8wJS1+1/DnMwJsJbbf5HpE6xl6ojeVtdIozk9vagsAsAqgELK lXhboyDFw5MOR+A12WEY9+DMkLYilfyahpnBuVjCoYZPBsM3FpNKJleIcBn9BtEQcp LXhnyZ0XqPjv2Cqg8fJ21ADh/ol+zYnYw17h46AtWSt/xY0jfk3u8LKejEyEwF1zRj KVzP2rsrzEr7g== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id B2D2D813D8; Wed, 8 Oct 2025 13:39:19 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id 211F29DA for ; Wed, 8 Oct 2025 13:39:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0723E4018F for ; Wed, 8 Oct 2025 13:39:18 +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 eLJP7YHYqWnn for ; Wed, 8 Oct 2025 13:39:16 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:41d0:203:375::bb; helo=out-187.mta1.migadu.com; envelope-from=vadim.fedorenko@linux.dev; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 81B6D408DA DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 81B6D408DA Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [IPv6:2001:41d0:203:375::bb]) by smtp2.osuosl.org (Postfix) with ESMTPS id 81B6D408DA for ; Wed, 8 Oct 2025 13:39:11 +0000 (UTC) Message-ID: <4c3f7f4e-a77e-4862-843e-4f96afd406e0@linux.dev> Date: Wed, 8 Oct 2025 14:38:50 +0100 MIME-Version: 1.0 To: Grzegorz Nitka , intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, Aleksandr Loktionov , Przemek Kitszel References: <20251008115811.1578695-1-grzegorz.nitka@intel.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20251008115811.1578695-1-grzegorz.nitka@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1759930748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WbFuK/4oiB1Zs+o79HnjX8bWNB1wUj6a043KWopg/Rk=; b=qszkx2paVl9iZQhaBFKHpqZ87U6pLV9VlO4knoXxBY9OQDTfrSuccqi7JHovD13huP2RvQ RoHZJQ+kpYNceIM/B2ZtDlf3cnd5JV15xlzk/JaKdYBVd9h49CnGUZG9LsUi0/sg6KUnXR EDZGBq0O4pNPBXthrIZx9KApG2q8k3Q= X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=qszkx2pa Subject: Re: [Intel-wired-lan] [PATCH iwl-net] ice: fix PTP cleanup on driver removal in error path 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 Sender: "Intel-wired-lan" On 08/10/2025 12:58, Grzegorz Nitka wrote: > Improve PTP feature cleanup in error path by adding explicit call to > ice_ptp_cleanup_pf in the case in which PTP feature is not fully > operational at the time of driver removal (which is indicated by > ptp->state flag). > At the driver probe, if PTP feature is supported, each PF adds its own > port to the list of ports controlled by ice_adapter object. > Analogously, at the driver remove, it's expected each PF is > responsible for removing previously added port from the list. > If for some reason (like errors in reset handling, NVM update etc.), PTP > feature has not rebuilt successfully, the driver is still responsible for > proper clearing ice_adapter port list. It's done by calling > ice_ptp_cleanup_pf function. > Otherwise, the following call trace is observed when ice_adapter object > is freed (port list is not empty, as it is expected at this stage): > > [ T93022] ------------[ cut here ]------------ > [ T93022] WARNING: CPU: 10 PID: 93022 at > ice/ice_adapter.c:67 ice_adapter_put+0xef/0x100 [ice] > ... > [ T93022] RIP: 0010:ice_adapter_put+0xef/0x100 [ice] > ... > [ T93022] Call Trace: > [ T93022] > [ T93022] ? ice_adapter_put+0xef/0x100 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > [ T93022] ? __warn.cold+0xb0/0x10e > [ T93022] ? ice_adapter_put+0xef/0x100 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > [ T93022] ? report_bug+0xd8/0x150 > [ T93022] ? handle_bug+0xe9/0x110 > [ T93022] ? exc_invalid_op+0x17/0x70 > [ T93022] ? asm_exc_invalid_op+0x1a/0x20 > [ T93022] ? ice_adapter_put+0xef/0x100 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > [ T93022] pci_device_remove+0x42/0xb0 > [ T93022] device_release_driver_internal+0x19f/0x200 > [ T93022] driver_detach+0x48/0x90 > [ T93022] bus_remove_driver+0x70/0xf0 > [ T93022] pci_unregister_driver+0x42/0xb0 > [ T93022] ice_module_exit+0x10/0xdb0 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > ... > [ T93022] ---[ end trace 0000000000000000 ]--- > [ T93022] ice: module unloaded > > Fixes: e800654e85b5 ("ice: Use ice_adapter for PTP shared data instead of auxdev") > Signed-off-by: Grzegorz Nitka > Reviewed-by: Aleksandr Loktionov > Reviewed-by: Przemek Kitszel > --- > drivers/net/ethernet/intel/ice/ice_ptp.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c > index fb0f6365a6d6..c43a7973d70f 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c > @@ -3282,8 +3282,10 @@ void ice_ptp_init(struct ice_pf *pf) > */ > void ice_ptp_release(struct ice_pf *pf) > { > - if (pf->ptp.state != ICE_PTP_READY) > + if (pf->ptp.state != ICE_PTP_READY) { > + ice_ptp_cleanup_pf(pf); > return; > + } > > pf->ptp.state = ICE_PTP_UNINIT; > ice_ptp_cleanup_pf() removes ptp->port.list_node, which is inited in ice_ptp_setup_pf(), but ice_ptp_init() may fail before ice_ptp_setup_pf() is called, and it will keep pf->ptp.state = ICE_PTP_ERROR. the cleanup then will work on uninitialized data. It looks like it's better to make proper clean up in ice_ptp_setup_pf() on error path rather then modify ice_ptp_cleanup_pf(). From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CC7224B15 for ; Wed, 8 Oct 2025 13:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759930756; cv=none; b=RqMwr/nDIuFYsB7dBboIN7p/iyawd8TR1KbYPFNvalRifK+ZYPTdHI7eLdl40DAzPVv9yhgkzl4nTmuSm2HZKk3EO8My9qEpJDy/ACvLQ8YH+iPODg7Lu3c/ykTyM+VrrVtNMmUmdapvxGioonDugIZ7TrTlioPavtpz/skld1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759930756; c=relaxed/simple; bh=uoZJouBg+QYQ13n81A6tW+PtmWDlDMHJayJc4vq5IzY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ONWgVifQKn5Hz2xOB5MPbfTP7nmdfLdAq6Z40znqhALa9HcWlD30azmnU6bmaE51YXoX4IvmzT2qXuJfB2UfsybhacSGy1fO1IwGmw1kuoG/p1WLknv9LgrQsugttF0zPGcdan80hX2DTjaDI7cfDahsRK+ghfmEgJDhdBkmmw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qszkx2pa; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qszkx2pa" Message-ID: <4c3f7f4e-a77e-4862-843e-4f96afd406e0@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1759930748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WbFuK/4oiB1Zs+o79HnjX8bWNB1wUj6a043KWopg/Rk=; b=qszkx2paVl9iZQhaBFKHpqZ87U6pLV9VlO4knoXxBY9OQDTfrSuccqi7JHovD13huP2RvQ RoHZJQ+kpYNceIM/B2ZtDlf3cnd5JV15xlzk/JaKdYBVd9h49CnGUZG9LsUi0/sg6KUnXR EDZGBq0O4pNPBXthrIZx9KApG2q8k3Q= Date: Wed, 8 Oct 2025 14:38:50 +0100 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH iwl-net] ice: fix PTP cleanup on driver removal in error path To: Grzegorz Nitka , intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, Aleksandr Loktionov , Przemek Kitszel References: <20251008115811.1578695-1-grzegorz.nitka@intel.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20251008115811.1578695-1-grzegorz.nitka@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 08/10/2025 12:58, Grzegorz Nitka wrote: > Improve PTP feature cleanup in error path by adding explicit call to > ice_ptp_cleanup_pf in the case in which PTP feature is not fully > operational at the time of driver removal (which is indicated by > ptp->state flag). > At the driver probe, if PTP feature is supported, each PF adds its own > port to the list of ports controlled by ice_adapter object. > Analogously, at the driver remove, it's expected each PF is > responsible for removing previously added port from the list. > If for some reason (like errors in reset handling, NVM update etc.), PTP > feature has not rebuilt successfully, the driver is still responsible for > proper clearing ice_adapter port list. It's done by calling > ice_ptp_cleanup_pf function. > Otherwise, the following call trace is observed when ice_adapter object > is freed (port list is not empty, as it is expected at this stage): > > [ T93022] ------------[ cut here ]------------ > [ T93022] WARNING: CPU: 10 PID: 93022 at > ice/ice_adapter.c:67 ice_adapter_put+0xef/0x100 [ice] > ... > [ T93022] RIP: 0010:ice_adapter_put+0xef/0x100 [ice] > ... > [ T93022] Call Trace: > [ T93022] > [ T93022] ? ice_adapter_put+0xef/0x100 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > [ T93022] ? __warn.cold+0xb0/0x10e > [ T93022] ? ice_adapter_put+0xef/0x100 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > [ T93022] ? report_bug+0xd8/0x150 > [ T93022] ? handle_bug+0xe9/0x110 > [ T93022] ? exc_invalid_op+0x17/0x70 > [ T93022] ? asm_exc_invalid_op+0x1a/0x20 > [ T93022] ? ice_adapter_put+0xef/0x100 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > [ T93022] pci_device_remove+0x42/0xb0 > [ T93022] device_release_driver_internal+0x19f/0x200 > [ T93022] driver_detach+0x48/0x90 > [ T93022] bus_remove_driver+0x70/0xf0 > [ T93022] pci_unregister_driver+0x42/0xb0 > [ T93022] ice_module_exit+0x10/0xdb0 [ice > 33d2647ad4f6d866d41eefff1806df37c68aef0c] > ... > [ T93022] ---[ end trace 0000000000000000 ]--- > [ T93022] ice: module unloaded > > Fixes: e800654e85b5 ("ice: Use ice_adapter for PTP shared data instead of auxdev") > Signed-off-by: Grzegorz Nitka > Reviewed-by: Aleksandr Loktionov > Reviewed-by: Przemek Kitszel > --- > drivers/net/ethernet/intel/ice/ice_ptp.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c > index fb0f6365a6d6..c43a7973d70f 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c > @@ -3282,8 +3282,10 @@ void ice_ptp_init(struct ice_pf *pf) > */ > void ice_ptp_release(struct ice_pf *pf) > { > - if (pf->ptp.state != ICE_PTP_READY) > + if (pf->ptp.state != ICE_PTP_READY) { > + ice_ptp_cleanup_pf(pf); > return; > + } > > pf->ptp.state = ICE_PTP_UNINIT; > ice_ptp_cleanup_pf() removes ptp->port.list_node, which is inited in ice_ptp_setup_pf(), but ice_ptp_init() may fail before ice_ptp_setup_pf() is called, and it will keep pf->ptp.state = ICE_PTP_ERROR. the cleanup then will work on uninitialized data. It looks like it's better to make proper clean up in ice_ptp_setup_pf() on error path rather then modify ice_ptp_cleanup_pf().