From patchwork Fri Aug 23 09:59:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 1975990 X-Patchwork-Delegate: anthony.l.nguyen@intel.com 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=Do72ewPe; 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 4Wqwkl4BBgz1yXY for ; Fri, 23 Aug 2024 20:08:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id DEC1881ED4; Fri, 23 Aug 2024 10:08:14 +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 cEJypOHrWmPr; Fri, 23 Aug 2024 10:08:14 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1BC2181ED2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1724407694; bh=23jwXYEeYOUGrucSxPg75uTgq445UrEvZw61XfGBtps=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Do72ewPe4fHsThLnmq/TeB4p9TyOJGrd//D0IHqZ29McmLDWUBv0gkN+7L9BKEGfV 2uuB8ixYXqjjjeHCO3QlcA7+dM13JtAHflE5Y/zpwuY76w58Pkf4qLHxVpKIlLMKiR yGMNwbZY9LzVxaPbXXpvcn5dudx4ON4QXfgTVr5soHTCK2NlCZgeYMZz6ASAnev1oD Xc7j5Nda4WRUIYxs8+Xx1kUZtju8GqJYyGPc7p6iZeVJHe9cjvw5Q3OcVxRoWM1oew ydXL/C7Jx4iCmt59mpsTEIMzM39XnuHIyN3iWUlIbrroa5cNs08nmRS1RTDLrqbzlX gZACS5QayKtqA== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 1BC2181ED2; Fri, 23 Aug 2024 10:08:14 +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 ash.osuosl.org (Postfix) with ESMTP id 14A381BF304 for ; Fri, 23 Aug 2024 10:08:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CB095403F9 for ; Fri, 23 Aug 2024 10:08:10 +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 YdzTseN5TWlP for ; Fri, 23 Aug 2024 10:08:10 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.10; helo=mgamail.intel.com; envelope-from=larysa.zaremba@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org C56CD40FB7 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C56CD40FB7 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by smtp2.osuosl.org (Postfix) with ESMTPS id C56CD40FB7 for ; Fri, 23 Aug 2024 10:08:09 +0000 (UTC) X-CSE-ConnectionGUID: zhg96y07S+iip/9QH4FLcA== X-CSE-MsgGUID: LoDbQD24Q0mr9SbJnNKktg== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="34285047" X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="34285047" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 03:08:09 -0700 X-CSE-ConnectionGUID: e+GTo2xFT4uObNT+SC3QBw== X-CSE-MsgGUID: B4xxOz1hRDiYosdN2hkX0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="62478984" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa008.jf.intel.com with ESMTP; 23 Aug 2024 03:08:05 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 718F333BD6; Fri, 23 Aug 2024 11:08:02 +0100 (IST) From: Larysa Zaremba To: intel-wired-lan@lists.osuosl.org, Tony Nguyen Date: Fri, 23 Aug 2024 11:59:29 +0200 Message-ID: <20240823095933.17922-5-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240823095933.17922-1-larysa.zaremba@intel.com> References: <20240823095933.17922-1-larysa.zaremba@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724407690; x=1755943690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZQepG22v/2yg4DruXjOlIUfQxcXCfOv/Ml8FpBV6ETs=; b=csgbBTh9HeI/haTmPQuGQYSiIiOo/0RzstyBKecG5Qc/Tkdl/8di6xFn b9Q1hAXElPXdtRaGKbMzPqtpI6Mi7KqmLVL1gOLYqeVRR8VkamGMoFhEy 9H9xg8pnMNbZNYaLH63fQqfpAEp+nzk/SzIwj8kzoPBxuD+DLRi7m7H29 qcf+xAVdmTQtQLwQj0NZ3QB4QI9jsb1ZSUVPOWHPmv8hnw9v63iFeA7A8 ogAZsIXGsu0SY9JeCtbMntyQuRt2+J7irPLfWg9BQi8fzLrJLyGRjfuM6 VwxJcjjwwr5nj2M7OEBlp4cqpieBqrw8JUwJvp2YyOhT8vHoah8Y8PQul w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Mailman-Original-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=csgbBTh9 Subject: [Intel-wired-lan] [PATCH iwl-net v4 4/6] ice: check ICE_VSI_DOWN under rtnl_lock when preparing for reset X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexei Starovoitov , Eric Dumazet , Maciej Fijalkowski , Daniel Borkmann , przemyslaw.kitszel@intel.com, John Fastabend , anirudh.venkataramanan@intel.com, Michal Kubiak , Jacob Keller , Jakub Kicinski , Paolo Abeni , Wojciech Drewek , Jesper Dangaard Brouer , Larysa Zaremba , magnus.karlsson@intel.com, Chandan Kumar Rout , Amritha Nambiar , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sridhar.samudrala@intel.com, bpf@vger.kernel.org, "David S. Miller" Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Consider the following scenario: .ndo_bpf() | ice_prepare_for_reset() | ________________________|_______________________________________| rtnl_lock() | | ice_down() | | | test_bit(ICE_VSI_DOWN) - true | | ice_dis_vsi() returns | ice_up() | | | proceeds to rebuild a running VSI | .ndo_bpf() is not the only rtnl-locked callback that toggles the interface to apply new configuration. Another example is .set_channels(). To avoid the race condition above, act only after reading ICE_VSI_DOWN under rtnl_lock. Fixes: 0f9d5027a749 ("ice: Refactor VSI allocation, deletion and rebuild flow") Reviewed-by: Wojciech Drewek Reviewed-by: Jacob Keller Tested-by: Chandan Kumar Rout Signed-off-by: Larysa Zaremba Reviewed-by: Maciej Fijalkowski --- drivers/net/ethernet/intel/ice/ice_lib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 14257e036d4b..2405e5ed9128 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2665,8 +2665,7 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked) */ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) { - if (test_bit(ICE_VSI_DOWN, vsi->state)) - return; + bool already_down = test_bit(ICE_VSI_DOWN, vsi->state); set_bit(ICE_VSI_NEEDS_RESTART, vsi->state); @@ -2674,15 +2673,16 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) if (netif_running(vsi->netdev)) { if (!locked) rtnl_lock(); - - ice_vsi_close(vsi); + already_down = test_bit(ICE_VSI_DOWN, vsi->state); + if (!already_down) + ice_vsi_close(vsi); if (!locked) rtnl_unlock(); - } else { + } else if (!already_down) { ice_vsi_close(vsi); } - } else if (vsi->type == ICE_VSI_CTRL) { + } else if (vsi->type == ICE_VSI_CTRL && !already_down) { ice_vsi_close(vsi); } }