Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp446451lqp; Mon, 10 Jun 2024 08:46:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCjYIer/wdFFsSp6e5Pz0wjRiv+1fy5sp9b1G2WTr5A4Zfn/bsxme60j5CSJQ9el3lkrqO5X/GHDw0ymiIxfM4xIHdup30+HzUvaPKjA== X-Google-Smtp-Source: AGHT+IFxlX5gI3Gm7YBhUVwYlBNNaOCbXdLIB8WOUbejvYpFM7TZ4udvK9lQt1ueyjal42B0iCw7 X-Received: by 2002:a05:6a20:1590:b0:1b7:4527:e291 with SMTP id adf61e73a8af0-1b74527e4femr3411475637.17.1718034367456; Mon, 10 Jun 2024 08:46:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718034367; cv=pass; d=google.com; s=arc-20160816; b=P8/mc41++79TaARXLpnQeClGJW9+/8ObxwoOTZVkjPXKnlVueHxYH0oF7zcJeo33Ca vs3nGCrvFIUOc1V1PLNjancxCFXZmqPqvHiWfKpYsJgOCD9CB1ApwbaF4wt15CucjtYG G9DN+zxbiywAxMBTYECdFeuioZ1XgTP8kGFGxYKfG3aohpAil13U4EHJ0dDt0vC+uZPG o0xBk3lf54KN7Z/OCRensUTZW10UVxO9Go2Addy2gNQNUVx/2pJSgqaFjnHejRDYu+F6 1evpClDNqOvntvwFIyJhtrkCjjHXevQ/h3n62ee/V80a5XNX06RAa9BMS17w96FKAYTp MNxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7Baz8DLhUc9XAfmN4gA7O9etp0E8ojSXqz4G74p/Tl8=; fh=G5KJICPoJlGhNYNFNgqLaBG6xG3QdJ7OIISd55bzHqg=; b=WS1F+ayBPzOFJfHj4eo3hDRO3+ASrMFm6jTzjqNCUEqjlSypY7k4wjPBVZPmsQRSeS 0J9jmnD4+rW37zGMw7dpwqCjvsgsxwXRuJ5E9L0TcoT0es4mvk5WZb5n5SZMQk0cC25E lljqaXvO1M7eZRrMxukSFF42wYlfdK2dgPumrFYuZygtrIK80DXiCbjlAH18Nls6v1U4 i0dGviIeGjj58hSz9wygJBFLzG/0I92XzESTJdMhqceclexH5cr9j3rG1Yhp79NBhtp/ PFxujhUwZY4sn7QTcxKqe9/cYgv9SCG/UKBuufKkZTYHIFNVi4g7hSQhTzp0AxeP5ton Llfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VKAB8jIh; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208502-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208502-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-703fd5640efsi4221877b3a.321.2024.06.10.08.46.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:46:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208502-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VKAB8jIh; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208502-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208502-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1785A28B3EB for ; Mon, 10 Jun 2024 15:46:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0954214532C; Mon, 10 Jun 2024 15:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VKAB8jIh" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 822D11422D5; Mon, 10 Jun 2024 15:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718034312; cv=none; b=CAzh0576/cTK/XrqX82InxtXzuH/Pvo2XMOMx6kMAd0W83cmI5eE4YGMH8fveERZgBHb35MAqPySAdEAUV+j/BkToHW1YG8esOJ0Vw+ZlTEf6eA1oX5wwCs2h0EozyfamkT/jM5F726QOddpHntCvyOwdIeGWggqd/tifM241tg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718034312; c=relaxed/simple; bh=1CJQhgdeQheVVIX/aqzTWo34167G3W6siXPTBXQpy9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GSz1Z8NIJJAyZtuyHRTrCmk+VI2u1gSqyUfLVEwiKbfP/qkdSQNQJJIa4oC/tZWM9kxGn+kj/xsmlJnhFd9yKEIihwg2Fdvim5zWDtBBITZxbOCzXp8iAl8hTPeQv6HXcRaVUZ6PAv3fXnB1lzNkcxXfM/tOTByMn+1F6M5hyFM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VKAB8jIh; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718034310; x=1749570310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1CJQhgdeQheVVIX/aqzTWo34167G3W6siXPTBXQpy9A=; b=VKAB8jIh8ycwOMgVFjKzHRRV7WPkLYAXdeFIlGsCd0TTi+Sb3UbKQbF3 tGFku7G+kVwTVjrP+jI74P3Z4ajiSzyLiHGuWEnDg507JsFF3bpAo144h gy0hSStBeq30jEKfzgQYet0XCrRC55sn9uwLPshrc09plBpcPRFzCr6jQ izXXsRmTEcvsI2gSEgLTerwwuPLmaODge17rzvUEH2s1D7CCdnQpK17so cTQU10zvatgwklqKo2RlLuuU4rxmc65hdZy8kPr6v/wQLlq2JXU3oAAPh 5TEy224sTvfIFXO7TWTF5a9O6GwO1phk/SiyEC4yn1NaGXbTB86RIeNJB Q==; X-CSE-ConnectionGUID: oRuzBhYmTBaCxQXchtgREQ== X-CSE-MsgGUID: fNFSYBdHS5yzjjTJ1RZH9w== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="26119868" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="26119868" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 08:45:10 -0700 X-CSE-ConnectionGUID: 6R3brtywTb2VXCSyRA/AmA== X-CSE-MsgGUID: JvFWDt5rTDmrEJjMGy02Uw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43679776" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa004.fm.intel.com with ESMTP; 10 Jun 2024 08:45: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 BB4B1312D7; Mon, 10 Jun 2024 16:44:50 +0100 (IST) From: Larysa Zaremba To: intel-wired-lan@lists.osuosl.org Cc: Larysa Zaremba , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Maciej Fijalkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, magnus.karlsson@intel.com, Michal Kubiak , Igor Bagnucki Subject: [PATCH iwl-net 2/3] ice: fix locking in ice_xsk_pool_setup() Date: Mon, 10 Jun 2024 17:37:14 +0200 Message-ID: <20240610153716.31493-3-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610153716.31493-1-larysa.zaremba@intel.com> References: <20240610153716.31493-1-larysa.zaremba@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit With ICE_CFG_BUSY PF state flag locking used in ice_xdp(), there is no need to lock with VSI state inside ice_xsk_pool_setup(). For robust synchronization the state between reset preparation and PF VSI rebuild has to be handled, in the same way as in ice_xdp_setup_prog(). Remove locking logic from ice_qp_dis() and ice_qp_ena() and skip those functions, if rebuild is pending. Fixes: 2d4238f55697 ("ice: Add support for AF_XDP") Reviewed-by: Igor Bagnucki Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 12 ++---------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 701a61d791dd..76590cfcaf68 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -941,6 +941,7 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog, enum ice_xdp_cfg cfg_type); int ice_destroy_xdp_rings(struct ice_vsi *vsi, enum ice_xdp_cfg cfg_type); void ice_map_xdp_rings(struct ice_vsi *vsi); +bool ice_rebuild_pending(struct ice_vsi *vsi); int ice_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, u32 flags); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index dc60d816a345..cd8be3c3b956 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -2994,7 +2994,7 @@ static int ice_max_xdp_frame_size(struct ice_vsi *vsi) * so it happens strictly before or after .ndo_bpf(). * In case it has happened before, we do not have anything attached to rings */ -static bool ice_rebuild_pending(struct ice_vsi *vsi) +bool ice_rebuild_pending(struct ice_vsi *vsi) { return ice_is_reset_in_progress(vsi->back->state) && !vsi->rx_rings[0]->desc; diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index 4e2020ab0825..6c95bebd7777 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -163,7 +163,6 @@ static int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx) struct ice_tx_ring *xdp_ring; struct ice_tx_ring *tx_ring; struct ice_rx_ring *rx_ring; - int timeout = 50; int fail = 0; int err; @@ -175,13 +174,6 @@ static int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx) xdp_ring = vsi->xdp_rings[q_idx]; q_vector = rx_ring->q_vector; - while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) { - timeout--; - if (!timeout) - return -EBUSY; - usleep_range(1000, 2000); - } - synchronize_net(); netif_trans_update(vsi->netdev); netif_carrier_off(vsi->netdev); @@ -251,7 +243,6 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) synchronize_net(); netif_tx_start_queue(netdev_get_tx_queue(vsi->netdev, q_idx)); netif_carrier_on(vsi->netdev); - clear_bit(ICE_CFG_BUSY, vsi->state); return fail; } @@ -379,7 +370,8 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) return -EINVAL; } - if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi); + if_running = !ice_rebuild_pending(vsi) && + netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi); if (if_running) { struct ice_rx_ring *rx_ring = vsi->rx_rings[qid]; -- 2.43.0