From patchwork Tue Nov 5 18:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun K Singh X-Patchwork-Id: 13863559 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 1E9CE20CCCD for ; Tue, 5 Nov 2024 21:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843360; cv=none; b=o5FRxr0gdMv6eMPTQ9zcnYKQ5NhmMXzppk5l4ObCK5GTiRzXWPcuBebW+nKBV8Mjia+7nT70yxwHqUDsWVnVbL9Hdxwp+KZrE+sYGTyv3VbvUns0BAZdhXUcTLZ13C6mYcjEQtBtKezvDHlm9ul2gjXinCKJQzsL9SdxuLiEtHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843360; c=relaxed/simple; bh=LNyBLsD0ODHmt5t/JMdR70uhaS5r3JHEat46z2yXsec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FIkPy+t0VyF4hjoE0pC8XGgrvW9nGuZ54WoB8b0Oh7sVHxT5UBnV2DVkzqhhI7Qo9/RUQ75lyFOeOmJ/AGV3/5Vj01z56YGWRlLHm188UU2ONHrTXUPE6hsjwRAdpo36Sp91lfx0UFLdquFN+D4vzlm5fWrXBZ0hHSXtXJjsEs4= 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=RmX92CLV; arc=none smtp.client-ip=198.175.65.17 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RmX92CLV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730843358; x=1762379358; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LNyBLsD0ODHmt5t/JMdR70uhaS5r3JHEat46z2yXsec=; b=RmX92CLVEzaaW4mKg+wyUcaoDOh+s6ti3CGofm3z1tagJQfxqxM6V/bS a2Y6dX9nYZoPu+i8arfggntAgOUQ5n5CTAZpB7hRzJFdBUAXpPBLjilcX CZt+gF9Y7i94r8xr+a7bwUlrb7n6Wkc1li6yOep0Tlm8tB/2D0V8Sy95F P9za1NHuqksHyAkaOUNcwnvCCBY78bcyk4a0Qj6kZslN1rxn+xufVUYbm yn1o8Y4pdDuJemNmfY15HuuYdfPMng7uW03W9jcNELa8PYmMyCmpwRCgM SqGFV+QJz436oILlXY0Kk2hZtvkpXzaFois6u26bbAkYMgfPlNGeuj0Mo A==; X-CSE-ConnectionGUID: ZA5YwiFiTHWYhBxIk3iLKA== X-CSE-MsgGUID: 3Jp/FyfUSGOZzYSGT2YgIw== X-IronPort-AV: E=McAfee;i="6700,10204,11247"; a="30735921" X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="30735921" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 13:49:16 -0800 X-CSE-ConnectionGUID: Zq9IaYIgREGRyD8n98hH4Q== X-CSE-MsgGUID: zpMM/4kOQeGLiSj8nEmZvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="85010410" Received: from coyotepass-34596-p1.jf.intel.com ([10.166.80.48]) by orviesa008.jf.intel.com with ESMTP; 05 Nov 2024 13:49:03 -0800 From: Tarun K Singh To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v1 1/4] idpf: Change function argument Date: Tue, 5 Nov 2024 13:48:56 -0500 Message-ID: <20241105184859.741473-2-tarun.k.singh@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241105184859.741473-1-tarun.k.singh@intel.com> References: <20241105184859.741473-1-tarun.k.singh@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Change idpf_vport_ctrl_lock's argument from netdev to adapter. Reviewed-by: Przemek Kitszel Signed-off-by: Tarun K Singh --- drivers/net/ethernet/intel/idpf/idpf.h | 16 ++--- .../net/ethernet/intel/idpf/idpf_ethtool.c | 59 ++++++++++--------- drivers/net/ethernet/intel/idpf/idpf_lib.c | 39 ++++++------ 3 files changed, 58 insertions(+), 56 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h index 66544faab710..d87ed50af681 100644 --- a/drivers/net/ethernet/intel/idpf/idpf.h +++ b/drivers/net/ethernet/intel/idpf/idpf.h @@ -788,27 +788,23 @@ static inline u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter) /** * idpf_vport_ctrl_lock - Acquire the vport control lock - * @netdev: Network interface device structure + * @adapter: private data struct * * This lock should be used by non-datapath code to protect against vport * destruction. */ -static inline void idpf_vport_ctrl_lock(struct net_device *netdev) +static inline void idpf_vport_ctrl_lock(struct idpf_adapter *adapter) { - struct idpf_netdev_priv *np = netdev_priv(netdev); - - mutex_lock(&np->adapter->vport_ctrl_lock); + mutex_lock(&adapter->vport_ctrl_lock); } /** * idpf_vport_ctrl_unlock - Release the vport control lock - * @netdev: Network interface device structure + * @adapter: private data struct */ -static inline void idpf_vport_ctrl_unlock(struct net_device *netdev) +static inline void idpf_vport_ctrl_unlock(struct idpf_adapter *adapter) { - struct idpf_netdev_priv *np = netdev_priv(netdev); - - mutex_unlock(&np->adapter->vport_ctrl_lock); + mutex_unlock(&adapter->vport_ctrl_lock); } void idpf_statistics_task(struct work_struct *work); diff --git a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c index 59b1a1a09996..e5ac3e5a50ce 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c +++ b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c @@ -14,22 +14,23 @@ static int idpf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, u32 __always_unused *rule_locs) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); switch (cmd->cmd) { case ETHTOOL_GRXRINGS: cmd->data = vport->num_rxq; - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return 0; default: break; } - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return -EOPNOTSUPP; } @@ -88,9 +89,8 @@ static int idpf_get_rxfh(struct net_device *netdev, int err = 0; u16 i; - idpf_vport_ctrl_lock(netdev); - adapter = np->adapter; + idpf_vport_ctrl_lock(adapter); if (!idpf_is_cap_ena_all(adapter, IDPF_RSS_CAPS, IDPF_CAP_RSS)) { err = -EOPNOTSUPP; @@ -112,7 +112,7 @@ static int idpf_get_rxfh(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -131,17 +131,15 @@ static int idpf_set_rxfh(struct net_device *netdev, struct netlink_ext_ack *extack) { struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_adapter *adapter = np->adapter; struct idpf_rss_data *rss_data; - struct idpf_adapter *adapter; struct idpf_vport *vport; int err = 0; u16 lut; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); - adapter = vport->adapter; - if (!idpf_is_cap_ena_all(adapter, IDPF_RSS_CAPS, IDPF_CAP_RSS)) { err = -EOPNOTSUPP; goto unlock_mutex; @@ -168,7 +166,7 @@ static int idpf_set_rxfh(struct net_device *netdev, err = idpf_config_rss(vport); unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -221,6 +219,7 @@ static void idpf_get_channels(struct net_device *netdev, static int idpf_set_channels(struct net_device *netdev, struct ethtool_channels *ch) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport_config *vport_config; unsigned int num_req_tx_q; unsigned int num_req_rx_q; @@ -235,7 +234,7 @@ static int idpf_set_channels(struct net_device *netdev, return -EINVAL; } - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); idx = vport->idx; @@ -279,7 +278,7 @@ static int idpf_set_channels(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -299,9 +298,10 @@ static void idpf_get_ringparam(struct net_device *netdev, struct kernel_ethtool_ringparam *kring, struct netlink_ext_ack *ext_ack) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); ring->rx_max_pending = IDPF_MAX_RXQ_DESC; @@ -311,7 +311,7 @@ static void idpf_get_ringparam(struct net_device *netdev, kring->tcp_data_split = idpf_vport_get_hsplit(vport); - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); } /** @@ -329,13 +329,14 @@ static int idpf_set_ringparam(struct net_device *netdev, struct kernel_ethtool_ringparam *kring, struct netlink_ext_ack *ext_ack) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport_user_config_data *config_data; u32 new_rx_count, new_tx_count; struct idpf_vport *vport; int i, err = 0; u16 idx; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); idx = vport->idx; @@ -394,7 +395,7 @@ static int idpf_set_ringparam(struct net_device *netdev, err = idpf_initiate_soft_reset(vport, IDPF_SR_Q_DESC_CHANGE); unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -869,6 +870,7 @@ static void idpf_get_ethtool_stats(struct net_device *netdev, u64 *data) { struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_adapter *adapter = np->adapter; struct idpf_vport_config *vport_config; struct idpf_vport *vport; unsigned int total = 0; @@ -876,11 +878,11 @@ static void idpf_get_ethtool_stats(struct net_device *netdev, bool is_splitq; u16 qtype; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (np->state != __IDPF_VPORT_UP) { - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return; } @@ -947,7 +949,7 @@ static void idpf_get_ethtool_stats(struct net_device *netdev, rcu_read_unlock(); - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); } /** @@ -1025,10 +1027,11 @@ static int idpf_get_q_coalesce(struct net_device *netdev, u32 q_num) { const struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_adapter *adapter = np->adapter; const struct idpf_vport *vport; int err = 0; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (np->state != __IDPF_VPORT_UP) @@ -1048,7 +1051,7 @@ static int idpf_get_q_coalesce(struct net_device *netdev, VIRTCHNL2_QUEUE_TYPE_TX); unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -1200,10 +1203,11 @@ static int idpf_set_coalesce(struct net_device *netdev, struct netlink_ext_ack *extack) { struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_adapter *adapter = np->adapter; struct idpf_vport *vport; int i, err = 0; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (np->state != __IDPF_VPORT_UP) @@ -1222,7 +1226,7 @@ static int idpf_set_coalesce(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -1238,22 +1242,23 @@ static int idpf_set_coalesce(struct net_device *netdev, static int idpf_set_per_q_coalesce(struct net_device *netdev, u32 q_num, struct ethtool_coalesce *ec) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; int err; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); err = idpf_set_q_coalesce(vport, ec, q_num, false); if (err) { - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } err = idpf_set_q_coalesce(vport, ec, q_num, true); - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c index b4fbb99bfad2..a870748a8be7 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c @@ -904,18 +904,18 @@ static void idpf_vport_stop(struct idpf_vport *vport) */ static int idpf_stop(struct net_device *netdev) { - struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; - if (test_bit(IDPF_REMOVE_IN_PROG, np->adapter->flags)) + if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags)) return 0; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); idpf_vport_stop(vport); - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return 0; } @@ -2098,16 +2098,14 @@ static int idpf_vport_manage_rss_lut(struct idpf_vport *vport) static int idpf_set_features(struct net_device *netdev, netdev_features_t features) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); netdev_features_t changed = netdev->features ^ features; - struct idpf_adapter *adapter; struct idpf_vport *vport; int err = 0; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); - adapter = vport->adapter; - if (idpf_is_reset_in_prog(adapter)) { dev_err(&adapter->pdev->dev, "Device is resetting, changing netdev features temporarily unavailable.\n"); err = -EBUSY; @@ -2134,7 +2132,7 @@ static int idpf_set_features(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -2153,15 +2151,16 @@ static int idpf_set_features(struct net_device *netdev, */ static int idpf_open(struct net_device *netdev) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; int err; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); err = idpf_vport_open(vport); - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -2175,17 +2174,18 @@ static int idpf_open(struct net_device *netdev) */ static int idpf_change_mtu(struct net_device *netdev, int new_mtu) { + struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; int err; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); WRITE_ONCE(netdev->mtu, new_mtu); err = idpf_initiate_soft_reset(vport, IDPF_SR_MTU_CHANGE); - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } @@ -2261,23 +2261,24 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb, static int idpf_set_mac(struct net_device *netdev, void *p) { struct idpf_netdev_priv *np = netdev_priv(netdev); + struct idpf_adapter *adapter = np->adapter; struct idpf_vport_config *vport_config; struct sockaddr *addr = p; struct idpf_vport *vport; int err = 0; - idpf_vport_ctrl_lock(netdev); + idpf_vport_ctrl_lock(adapter); vport = idpf_netdev_to_vport(netdev); - if (!idpf_is_cap_ena(vport->adapter, IDPF_OTHER_CAPS, + if (!idpf_is_cap_ena(adapter, IDPF_OTHER_CAPS, VIRTCHNL2_CAP_MACFILTER)) { - dev_info(&vport->adapter->pdev->dev, "Setting MAC address is not supported\n"); + dev_info(&adapter->pdev->dev, "Setting MAC address is not supported\n"); err = -EOPNOTSUPP; goto unlock_mutex; } if (!is_valid_ether_addr(addr->sa_data)) { - dev_info(&vport->adapter->pdev->dev, "Invalid MAC address: %pM\n", + dev_info(&adapter->pdev->dev, "Invalid MAC address: %pM\n", addr->sa_data); err = -EADDRNOTAVAIL; goto unlock_mutex; @@ -2286,7 +2287,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p) if (ether_addr_equal(netdev->dev_addr, addr->sa_data)) goto unlock_mutex; - vport_config = vport->adapter->vport_config[vport->idx]; + vport_config = adapter->vport_config[vport->idx]; err = idpf_add_mac_filter(vport, np, addr->sa_data, false); if (err) { __idpf_del_mac_filter(vport_config, addr->sa_data); @@ -2300,7 +2301,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p) eth_hw_addr_set(netdev, addr->sa_data); unlock_mutex: - idpf_vport_ctrl_unlock(netdev); + idpf_vport_ctrl_unlock(adapter); return err; } From patchwork Tue Nov 5 18:48:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun K Singh X-Patchwork-Id: 13863560 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 6CDC92161F7 for ; Tue, 5 Nov 2024 21:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843360; cv=none; b=Z+AOs5n7i3ak4GDqSNLHsf9Cb7I11dssjLx4n0JMnqI0VesslrPIIfOZyjlSVvx4M8Y5rDQc4tlv5j2dtf9y65MziXBYohlXP8v3H0lyPjSd6kOAm3fE+WHRrcmKHevGO8/ASFiZABXYetqD20hLXaFpi+wf34MMJVIWAdHbjH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843360; c=relaxed/simple; bh=SqivNwsZCDrv+Qryo7XrCbD1oc37ghHHBjHvf3JsNiM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XOBNbwn04YcwncthG0PoLucU+AbHzI+C7I8eXsChA3R9F68HO+yUtqA9UEOGC1SLijVM6DfRl4SfafLzIkugAV/zmZMAQWMmMdHPLT7rsrfCV4bDOsn1HYdTcKFztQ43iIq15qS/7afbW9ngr7fCLd+xmmjjUrbj5ZYghxELOKc= 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=msuiQjBi; arc=none smtp.client-ip=198.175.65.17 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="msuiQjBi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730843359; x=1762379359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SqivNwsZCDrv+Qryo7XrCbD1oc37ghHHBjHvf3JsNiM=; b=msuiQjBizm6MqvOAPGQDmBSk6nl7JCdFTFixhTAUEhVan8muP0/pJv3+ 36iSlvbMnPar3fYvEy6KNSlivdXnhGGPlQgq2f+Gtbj2kj15YkMKaDw/u v5a8Lu4QJFhatfDFjEVWy0v42lGPC5y83IM+hInaqPJ42hAaeO1PVEbZe JNij43WltRCfm3cwTrQF51lblM+eE6lYvSwJBYzxbzIcZYQBLstTU+whz SckPryyE7EZkEv5XJ5PJQdSMRuRfv82zfJfT26OOdWUR5AGzw3OtOs/Ka slMDon6MbgnspbY9F12vVKk+foksZB4sitLfyUBY24vhhg6aX41KGHnAw g==; X-CSE-ConnectionGUID: 2SB9txhnQkGxLuRhoiWCBQ== X-CSE-MsgGUID: ytugP9pgStGRwxLS65SQ2w== X-IronPort-AV: E=McAfee;i="6700,10204,11247"; a="30735923" X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="30735923" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 13:49:16 -0800 X-CSE-ConnectionGUID: 23Rl6e5HRgSRE/Xx1pSwgg== X-CSE-MsgGUID: ENh/6zA8RoeyqQBS8K5QWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="85010416" Received: from coyotepass-34596-p1.jf.intel.com ([10.166.80.48]) by orviesa008.jf.intel.com with ESMTP; 05 Nov 2024 13:49:04 -0800 From: Tarun K Singh To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v1 2/4] idpf: rename vport_ctrl_lock Date: Tue, 5 Nov 2024 13:48:57 -0500 Message-ID: <20241105184859.741473-3-tarun.k.singh@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241105184859.741473-1-tarun.k.singh@intel.com> References: <20241105184859.741473-1-tarun.k.singh@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Rename 'vport_ctrl_lock' to 'vport_cfg_lock'. Rename related functions name for lock and unlock. Reviewed-by: Przemek Kitszel Signed-off-by: Tarun K Singh --- drivers/net/ethernet/intel/idpf/idpf.h | 16 +++---- .../net/ethernet/intel/idpf/idpf_ethtool.c | 46 +++++++++---------- drivers/net/ethernet/intel/idpf/idpf_lib.c | 24 +++++----- drivers/net/ethernet/intel/idpf/idpf_main.c | 4 +- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h index d87ed50af681..8dea2dd784af 100644 --- a/drivers/net/ethernet/intel/idpf/idpf.h +++ b/drivers/net/ethernet/intel/idpf/idpf.h @@ -526,7 +526,7 @@ struct idpf_vc_xn_manager; * @crc_enable: Enable CRC insertion offload * @req_tx_splitq: TX split or single queue model to request * @req_rx_splitq: RX split or single queue model to request - * @vport_ctrl_lock: Lock to protect the vport control flow + * @vport_cfg_lock: Lock to protect the vport config flow * @vector_lock: Lock to protect vector distribution * @queue_lock: Lock to protect queue distribution * @vc_buf_lock: Lock to protect virtchnl buffer @@ -583,7 +583,7 @@ struct idpf_adapter { bool req_tx_splitq; bool req_rx_splitq; - struct mutex vport_ctrl_lock; + struct mutex vport_cfg_lock; struct mutex vector_lock; struct mutex queue_lock; struct mutex vc_buf_lock; @@ -787,24 +787,24 @@ static inline u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter) } /** - * idpf_vport_ctrl_lock - Acquire the vport control lock + * idpf_vport_cfg_lock - Acquire the vport config lock * @adapter: private data struct * * This lock should be used by non-datapath code to protect against vport * destruction. */ -static inline void idpf_vport_ctrl_lock(struct idpf_adapter *adapter) +static inline void idpf_vport_cfg_lock(struct idpf_adapter *adapter) { - mutex_lock(&adapter->vport_ctrl_lock); + mutex_lock(&adapter->vport_cfg_lock); } /** - * idpf_vport_ctrl_unlock - Release the vport control lock + * idpf_vport_cfg_unlock - Release the vport config lock * @adapter: private data struct */ -static inline void idpf_vport_ctrl_unlock(struct idpf_adapter *adapter) +static inline void idpf_vport_cfg_unlock(struct idpf_adapter *adapter) { - mutex_unlock(&adapter->vport_ctrl_lock); + mutex_unlock(&adapter->vport_cfg_lock); } void idpf_statistics_task(struct work_struct *work); diff --git a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c index e5ac3e5a50ce..b3ed1d9a80ae 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c +++ b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c @@ -17,20 +17,20 @@ static int idpf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); switch (cmd->cmd) { case ETHTOOL_GRXRINGS: cmd->data = vport->num_rxq; - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return 0; default: break; } - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return -EOPNOTSUPP; } @@ -90,7 +90,7 @@ static int idpf_get_rxfh(struct net_device *netdev, u16 i; adapter = np->adapter; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); if (!idpf_is_cap_ena_all(adapter, IDPF_RSS_CAPS, IDPF_CAP_RSS)) { err = -EOPNOTSUPP; @@ -112,7 +112,7 @@ static int idpf_get_rxfh(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -137,7 +137,7 @@ static int idpf_set_rxfh(struct net_device *netdev, int err = 0; u16 lut; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (!idpf_is_cap_ena_all(adapter, IDPF_RSS_CAPS, IDPF_CAP_RSS)) { @@ -166,7 +166,7 @@ static int idpf_set_rxfh(struct net_device *netdev, err = idpf_config_rss(vport); unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -234,7 +234,7 @@ static int idpf_set_channels(struct net_device *netdev, return -EINVAL; } - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); idx = vport->idx; @@ -278,7 +278,7 @@ static int idpf_set_channels(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -301,7 +301,7 @@ static void idpf_get_ringparam(struct net_device *netdev, struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev); struct idpf_vport *vport; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); ring->rx_max_pending = IDPF_MAX_RXQ_DESC; @@ -311,7 +311,7 @@ static void idpf_get_ringparam(struct net_device *netdev, kring->tcp_data_split = idpf_vport_get_hsplit(vport); - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); } /** @@ -336,7 +336,7 @@ static int idpf_set_ringparam(struct net_device *netdev, int i, err = 0; u16 idx; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); idx = vport->idx; @@ -395,7 +395,7 @@ static int idpf_set_ringparam(struct net_device *netdev, err = idpf_initiate_soft_reset(vport, IDPF_SR_Q_DESC_CHANGE); unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -878,11 +878,11 @@ static void idpf_get_ethtool_stats(struct net_device *netdev, bool is_splitq; u16 qtype; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (np->state != __IDPF_VPORT_UP) { - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return; } @@ -949,7 +949,7 @@ static void idpf_get_ethtool_stats(struct net_device *netdev, rcu_read_unlock(); - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); } /** @@ -1031,7 +1031,7 @@ static int idpf_get_q_coalesce(struct net_device *netdev, const struct idpf_vport *vport; int err = 0; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (np->state != __IDPF_VPORT_UP) @@ -1051,7 +1051,7 @@ static int idpf_get_q_coalesce(struct net_device *netdev, VIRTCHNL2_QUEUE_TYPE_TX); unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -1207,7 +1207,7 @@ static int idpf_set_coalesce(struct net_device *netdev, struct idpf_vport *vport; int i, err = 0; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (np->state != __IDPF_VPORT_UP) @@ -1226,7 +1226,7 @@ static int idpf_set_coalesce(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -1246,19 +1246,19 @@ static int idpf_set_per_q_coalesce(struct net_device *netdev, u32 q_num, struct idpf_vport *vport; int err; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); err = idpf_set_q_coalesce(vport, ec, q_num, false); if (err) { - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } err = idpf_set_q_coalesce(vport, ec, q_num, true); - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c index a870748a8be7..778dc71fbf4a 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c @@ -910,12 +910,12 @@ static int idpf_stop(struct net_device *netdev) if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags)) return 0; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); idpf_vport_stop(vport); - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return 0; } @@ -1733,7 +1733,7 @@ static int idpf_init_hard_reset(struct idpf_adapter *adapter) int err; u16 i; - mutex_lock(&adapter->vport_ctrl_lock); + mutex_lock(&adapter->vport_cfg_lock); dev_info(dev, "Device HW Reset initiated\n"); @@ -1798,7 +1798,7 @@ static int idpf_init_hard_reset(struct idpf_adapter *adapter) msleep(100); unlock_mutex: - mutex_unlock(&adapter->vport_ctrl_lock); + mutex_unlock(&adapter->vport_cfg_lock); return err; } @@ -2103,7 +2103,7 @@ static int idpf_set_features(struct net_device *netdev, struct idpf_vport *vport; int err = 0; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (idpf_is_reset_in_prog(adapter)) { @@ -2132,7 +2132,7 @@ static int idpf_set_features(struct net_device *netdev, } unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -2155,12 +2155,12 @@ static int idpf_open(struct net_device *netdev) struct idpf_vport *vport; int err; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); err = idpf_vport_open(vport); - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -2178,14 +2178,14 @@ static int idpf_change_mtu(struct net_device *netdev, int new_mtu) struct idpf_vport *vport; int err; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); WRITE_ONCE(netdev->mtu, new_mtu); err = idpf_initiate_soft_reset(vport, IDPF_SR_MTU_CHANGE); - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } @@ -2267,7 +2267,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p) struct idpf_vport *vport; int err = 0; - idpf_vport_ctrl_lock(adapter); + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); if (!idpf_is_cap_ena(adapter, IDPF_OTHER_CAPS, @@ -2301,7 +2301,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p) eth_hw_addr_set(netdev, addr->sa_data); unlock_mutex: - idpf_vport_ctrl_unlock(adapter); + idpf_vport_cfg_unlock(adapter); return err; } diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c index db476b3314c8..0522b3a6f42c 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_main.c +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c @@ -72,7 +72,7 @@ static void idpf_remove(struct pci_dev *pdev) kfree(adapter->vcxn_mngr); adapter->vcxn_mngr = NULL; - mutex_destroy(&adapter->vport_ctrl_lock); + mutex_destroy(&adapter->vport_cfg_lock); mutex_destroy(&adapter->vector_lock); mutex_destroy(&adapter->queue_lock); mutex_destroy(&adapter->vc_buf_lock); @@ -229,7 +229,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_cfg_hw; } - mutex_init(&adapter->vport_ctrl_lock); + mutex_init(&adapter->vport_cfg_lock); mutex_init(&adapter->vector_lock); mutex_init(&adapter->queue_lock); mutex_init(&adapter->vc_buf_lock); From patchwork Tue Nov 5 18:48:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun K Singh X-Patchwork-Id: 13863561 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 4625C216427 for ; Tue, 5 Nov 2024 21:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843362; cv=none; b=HErXBB77ntwwzKY8f/XiSFfl9xwjgZiJqnHM3KDt8ZlU80tEH+cozc34yE4tWIN4tF9W9VSXPOAlqnydilabJ8HT1G9gtnDyVhGXkmflDda7B3HeUgDFZxICKORJffuGPFBABwMoWNz2gMYeOsT9eSevyIDO7iPuejvw6n8HQFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843362; c=relaxed/simple; bh=fs47b3k7TnzdYnjiKW2cihXESV17iIsj1HH+Y7Az+Ng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sHZADtvydSb3t3BUfx85w86NjGG66GAs/VWC29/srsJI9VPnnV2Am9hpZYbOy8W1jOF4wOz29b6ShvqZquRGJ78VG5QKLvW7tB4YalJjA1qDErDvAR/FqF9eS2SisYQawzEIBpchFOhDVVu1ZD4A1HBa+GqlOWm9aSQCvjIgVsM= 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=X8XsUjR7; arc=none smtp.client-ip=198.175.65.17 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X8XsUjR7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730843361; x=1762379361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fs47b3k7TnzdYnjiKW2cihXESV17iIsj1HH+Y7Az+Ng=; b=X8XsUjR7vrVwq1KPZUGGy7zU1x+yCYqLpWgjNKtzZbdj0w1ZntrXddYB xSlPg3A5r4ikCEj3FB1BVxWYtSdZRYtx98SmcF5oGNVghFb2ZjBbwBesa 2AHD9abUJ2FCRXrhKybs4BBcLAqJNq8ccCVJYfbs9b8R/KLJKlOWiWEN8 6tMMGBSWRpZSXWKmq4psQ/24xt+kdFzIWU5FNkNxGMzV3MSjjIN5W+oTu QPNEzbeSrPjOip/zkaL9u2MJscSEvdXAZIhndPXEPYIqMq7XBXwjdVXj8 yNP/u6zHDxZNTEdCXe9RP5sBQtbfyRolNtE4y8fL7xsqnbn5+PY4ipnYE g==; X-CSE-ConnectionGUID: PrWTGTzmSUyj2IyNJpu0Mw== X-CSE-MsgGUID: wtN99q6TRKm2gnFYa39CFA== X-IronPort-AV: E=McAfee;i="6700,10204,11247"; a="30735925" X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="30735925" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 13:49:16 -0800 X-CSE-ConnectionGUID: Wg8QJlc8TxOSOUWkDNs8Dw== X-CSE-MsgGUID: +hsLn0LgSgeVBVEHzhFFQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="85010419" Received: from coyotepass-34596-p1.jf.intel.com ([10.166.80.48]) by orviesa008.jf.intel.com with ESMTP; 05 Nov 2024 13:49:06 -0800 From: Tarun K Singh To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v1 3/4] idpf: Add init, reinit, and deinit control lock Date: Tue, 5 Nov 2024 13:48:58 -0500 Message-ID: <20241105184859.741473-4-tarun.k.singh@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241105184859.741473-1-tarun.k.singh@intel.com> References: <20241105184859.741473-1-tarun.k.singh@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add new 'vport_init_lock' to prevent locking issue. The existing 'vport_cfg_lock' was controlling the vport initialization, re-initialization due to reset, and de-initialization of code flow. In addition to controlling the above behavior it was also controlling the parallel netdevice calls such as open/close from Linux OS, which can happen independent of re-init or de-init of the vport(s). If first one such as re-init or de-init is going on then the second operation to config the netdevice with OS should not take place. The first operation (init or de-init) takes the precedence if both are to happen simultaneously. Use of single lock cause deadlock and inconsistent behavior of code flow. E.g. when driver undergoes reset via 'idpf_init_hard_reset', it acquires the 'vport_cfg_lock', and during this process it tries to unregister netdevice which may call 'idpf_stop' which tries to acquire same lock causing it to deadlock. To address above, add new lock 'vport_init_lock' which control the initialization, re-initialization, and de-initialization flow. The 'vport_cfg_lock' now exclusively controls the vport config operations. Add vport config lock around 'idpf_vport_stop()' and 'idpf_vport_open()' to protect close and open operation at the same time. Add vport init lock around 'idpf_sriv_configure()' to protect it from load and removal path. To accomplish it, use existing function as wrapper and introduce another function 'idpf_sriov_config_vfs' which is used inside the lock. In idpf_remove, change 'idpf_sriov_configure' to 'idpf_sriov_config_vfs', and move inside the init lock. Use these two locks in the following precedence: 'vport_init_lock' first, then 'vport_cfg_lock'. Fixes: 8077c727561a ("idpf: add controlq init and reset checks") Reviewed-by: Przemek Kitszel Reviewed-by: Madhu Chittim Signed-off-by: Tarun K Singh --- drivers/net/ethernet/intel/idpf/idpf.h | 25 +++++++++++++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 41 ++++++++++++++++++--- drivers/net/ethernet/intel/idpf/idpf_main.c | 7 +++- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h index 8dea2dd784af..34dbdc7d6c88 100644 --- a/drivers/net/ethernet/intel/idpf/idpf.h +++ b/drivers/net/ethernet/intel/idpf/idpf.h @@ -526,6 +526,7 @@ struct idpf_vc_xn_manager; * @crc_enable: Enable CRC insertion offload * @req_tx_splitq: TX split or single queue model to request * @req_rx_splitq: RX split or single queue model to request + * @vport_init_lock: Lock to protect vport init, re-init, and deinit flow * @vport_cfg_lock: Lock to protect the vport config flow * @vector_lock: Lock to protect vector distribution * @queue_lock: Lock to protect queue distribution @@ -583,6 +584,7 @@ struct idpf_adapter { bool req_tx_splitq; bool req_rx_splitq; + struct mutex vport_init_lock; struct mutex vport_cfg_lock; struct mutex vector_lock; struct mutex queue_lock; @@ -786,6 +788,28 @@ static inline u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter) return le16_to_cpu(adapter->caps.max_tx_hdr_size); } +/** + * idpf_vport_init_lock -acquire init/deinit control lock + * @adapter: private data struct + * + * It controls and protect vport initialization, re-initialization, + * and deinitialization code flow and its resources. This + * lock is only used by non-datapath code. + */ +static inline void idpf_vport_init_lock(struct idpf_adapter *adapter) +{ + mutex_lock(&adapter->vport_init_lock); +} + +/** + * idpf_vport_init_unlock - release vport init lock + * @adapter: private data struct + */ +static inline void idpf_vport_init_unlock(struct idpf_adapter *adapter) +{ + mutex_unlock(&adapter->vport_init_lock); +} + /** * idpf_vport_cfg_lock - Acquire the vport config lock * @adapter: private data struct @@ -827,6 +851,7 @@ void idpf_set_ethtool_ops(struct net_device *netdev); void idpf_vport_intr_write_itr(struct idpf_q_vector *q_vector, u16 itr, bool tx); int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs); +int idpf_sriov_config_vfs(struct pci_dev *pdev, int num_vfs); u8 idpf_vport_get_hsplit(const struct idpf_vport *vport); bool idpf_vport_set_hsplit(const struct idpf_vport *vport, u8 val); diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c index 778dc71fbf4a..931d0f988c95 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c @@ -1000,7 +1000,10 @@ static void idpf_vport_dealloc(struct idpf_vport *vport) unsigned int i = vport->idx; idpf_deinit_mac_addr(vport); + + idpf_vport_cfg_lock(adapter); idpf_vport_stop(vport); + idpf_vport_cfg_unlock(adapter); if (!test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags)) idpf_decfg_netdev(vport); @@ -1522,8 +1525,11 @@ void idpf_init_task(struct work_struct *work) /* Once state is put into DOWN, driver is ready for dev_open */ np = netdev_priv(vport->netdev); np->state = __IDPF_VPORT_DOWN; - if (test_and_clear_bit(IDPF_VPORT_UP_REQUESTED, vport_config->flags)) + if (test_and_clear_bit(IDPF_VPORT_UP_REQUESTED, vport_config->flags)) { + idpf_vport_cfg_lock(adapter); idpf_vport_open(vport); + idpf_vport_cfg_unlock(adapter); + } /* Spawn and return 'idpf_init_task' work queue until all the * default vports are created @@ -1601,17 +1607,19 @@ static int idpf_sriov_ena(struct idpf_adapter *adapter, int num_vfs) } /** - * idpf_sriov_configure - Configure the requested VFs + * idpf_sriov_config_vfs - Configure the requested VFs * @pdev: pointer to a pci_dev structure * @num_vfs: number of vfs to allocate * * Enable or change the number of VFs. Called when the user updates the number * of VFs in sysfs. **/ -int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs) +int idpf_sriov_config_vfs(struct pci_dev *pdev, int num_vfs) { struct idpf_adapter *adapter = pci_get_drvdata(pdev); + lockdep_assert_held(&adapter->vport_init_lock); + if (!idpf_is_cap_ena(adapter, IDPF_OTHER_CAPS, VIRTCHNL2_CAP_SRIOV)) { dev_info(&pdev->dev, "SR-IOV is not supported on this device\n"); @@ -1634,6 +1642,26 @@ int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs) return 0; } +/** + * idpf_sriov_configure - Call idpf_sriov_config_vfs to configure + * @pdev: pointer to a pci_dev structure + * @num_vfs: number of vfs to allocate + * + * Enable or change the number of VFs. Called when the user updates the number + * of VFs in sysfs. + **/ +int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs) +{ + struct idpf_adapter *adapter = pci_get_drvdata(pdev); + int ret; + + idpf_vport_init_lock(adapter); + ret = idpf_sriov_config_vfs(pdev, num_vfs); + idpf_vport_init_unlock(adapter); + + return ret; +} + /** * idpf_deinit_task - Device deinit routine * @adapter: Driver specific private structure @@ -1733,7 +1761,7 @@ static int idpf_init_hard_reset(struct idpf_adapter *adapter) int err; u16 i; - mutex_lock(&adapter->vport_cfg_lock); + idpf_vport_init_lock(adapter); dev_info(dev, "Device HW Reset initiated\n"); @@ -1798,7 +1826,7 @@ static int idpf_init_hard_reset(struct idpf_adapter *adapter) msleep(100); unlock_mutex: - mutex_unlock(&adapter->vport_cfg_lock); + idpf_vport_init_unlock(adapter); return err; } @@ -2155,6 +2183,9 @@ static int idpf_open(struct net_device *netdev) struct idpf_vport *vport; int err; + if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags)) + return 0; + idpf_vport_cfg_lock(adapter); vport = idpf_netdev_to_vport(netdev); diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c index 0522b3a6f42c..04bbc048c829 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_main.c +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c @@ -28,10 +28,13 @@ static void idpf_remove(struct pci_dev *pdev) * end up in bad state. */ cancel_delayed_work_sync(&adapter->vc_event_task); + + idpf_vport_init_lock(adapter); if (adapter->num_vfs) - idpf_sriov_configure(pdev, 0); + idpf_sriov_config_vfs(pdev, 0); idpf_vc_core_deinit(adapter); + idpf_vport_init_unlock(adapter); /* Be a good citizen and leave the device clean on exit */ adapter->dev_ops.reg_ops.trigger_reset(adapter, IDPF_HR_FUNC_RESET); @@ -72,6 +75,7 @@ static void idpf_remove(struct pci_dev *pdev) kfree(adapter->vcxn_mngr); adapter->vcxn_mngr = NULL; + mutex_destroy(&adapter->vport_init_lock); mutex_destroy(&adapter->vport_cfg_lock); mutex_destroy(&adapter->vector_lock); mutex_destroy(&adapter->queue_lock); @@ -229,6 +233,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_cfg_hw; } + mutex_init(&adapter->vport_init_lock); mutex_init(&adapter->vport_cfg_lock); mutex_init(&adapter->vector_lock); mutex_init(&adapter->queue_lock); From patchwork Tue Nov 5 18:48:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun K Singh X-Patchwork-Id: 13863562 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 CFC1E21620F for ; Tue, 5 Nov 2024 21:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843362; cv=none; b=bEwqbIPsVV/NyZw1qpm5AyRa/GBrq2nS27eNkaPYpGzWe2TAETmld4nQW15bmX4pExTPGsc6mtS45U0X0k5Hw62YRaum0jIRKev4/8pFmoWxqQYGYexRFJR2M3DXrQ3HGkmpKQ1DWd6Z2jz/YwVLQlFpaKM9szz3KQfMMsJ/GuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843362; c=relaxed/simple; bh=cPWS4f0r9yWak9dT8ctCM7VCSSxRTsgXjzI+Wr46d5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uxlaeLZTBIDfhKcF1M3PuuYA2+XWwR7HasIscu3nQpPDD8uMl9sSZBHAJhCDupl5c/KnEcbvl+Ijvl9FetSEj9doKQl++5QWcw9equIH1e2VO+BoZode1da24XcAF1QdLgztu8iVHRjA6moVc/Gi3FljHDPEO8EfymGFvf7pWbM= 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=MUm4Tv5c; arc=none smtp.client-ip=198.175.65.17 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MUm4Tv5c" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730843361; x=1762379361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cPWS4f0r9yWak9dT8ctCM7VCSSxRTsgXjzI+Wr46d5I=; b=MUm4Tv5cBYEVJQI+GAzdhHNb7C5AK2aijYlN6gL4cBQ2TO0N3hfyJScQ q7yowc2wL1uQFjT+hGRT2hSM2D4ZUn8icjL+Yfbg6ERS/POz8E12DINPe hYo68ZSiC8jWHfZh94KXdfLP1nXQ7TNAFyBNw0/ZVpnE4YOX3OOh7peBp HUcsQKcryc6+tRQcRrh8cMWybXSt3U/9CQtB/vzkptINqpDhrGAaqXU/L kMvNB0v2VQV5ZTpueetedQIMyLU/IWI7FcxL6edkse/uukCYTUBxUPHmQ aihsK0KXVlcwLHZznlnMsBt/k2MZbKLJz4CCMDTYG/AvHJ1xTfqZqhMVX A==; X-CSE-ConnectionGUID: N3CT8yWrTwuFm6+1/da/NQ== X-CSE-MsgGUID: bO0/FoKuRg2k2IohJ6y7tA== X-IronPort-AV: E=McAfee;i="6700,10204,11247"; a="30735927" X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="30735927" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 13:49:16 -0800 X-CSE-ConnectionGUID: rdnFo2JFTYKAgEeC/gfb+g== X-CSE-MsgGUID: dE6mHU+ISQeE0T42JJf4Ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,261,1725346800"; d="scan'208";a="85010425" Received: from coyotepass-34596-p1.jf.intel.com ([10.166.80.48]) by orviesa008.jf.intel.com with ESMTP; 05 Nov 2024 13:49:06 -0800 From: Tarun K Singh To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v1 4/4] idpf: add lock class key Date: Tue, 5 Nov 2024 13:48:59 -0500 Message-ID: <20241105184859.741473-5-tarun.k.singh@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241105184859.741473-1-tarun.k.singh@intel.com> References: <20241105184859.741473-1-tarun.k.singh@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Ahmed Zaki Add lock class key changes to prevent lockdep from complaining when PF reset the VFs. Signed-off-by: Ahmed Zaki Reviewed-by: Przemek Kitszel Reviewed-by: Madhu Chittim Signed-off-by: Tarun K Singh --- drivers/net/ethernet/intel/idpf/idpf_main.c | 32 +++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c index 04bbc048c829..082026c2a7ab 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_main.c +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c @@ -11,6 +11,10 @@ MODULE_DESCRIPTION(DRV_SUMMARY); MODULE_IMPORT_NS(LIBETH); MODULE_LICENSE("GPL"); +/* Prevent lockdep from complaining when PF reset the VFs */ +static struct lock_class_key idpf_pf_vport_init_lock_key; +static struct lock_class_key idpf_pf_work_lock_key; + /** * idpf_remove - Device removal routine * @pdev: PCI device information struct @@ -140,9 +144,25 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) adapter->req_tx_splitq = true; adapter->req_rx_splitq = true; + mutex_init(&adapter->vport_init_lock); + mutex_init(&adapter->vport_cfg_lock); + mutex_init(&adapter->vector_lock); + mutex_init(&adapter->queue_lock); + mutex_init(&adapter->vc_buf_lock); + + INIT_DELAYED_WORK(&adapter->init_task, idpf_init_task); + INIT_DELAYED_WORK(&adapter->serv_task, idpf_service_task); + INIT_DELAYED_WORK(&adapter->mbx_task, idpf_mbx_task); + INIT_DELAYED_WORK(&adapter->stats_task, idpf_statistics_task); + INIT_DELAYED_WORK(&adapter->vc_event_task, idpf_vc_event_task); + switch (ent->device) { case IDPF_DEV_ID_PF: idpf_dev_ops_init(adapter); + lockdep_set_class(&adapter->vport_init_lock, + &idpf_pf_vport_init_lock_key); + lockdep_init_map(&adapter->vc_event_task.work.lockdep_map, + "idpf-PF-vc-work", &idpf_pf_work_lock_key, 0); break; case IDPF_DEV_ID_VF: idpf_vf_dev_ops_init(adapter); @@ -233,18 +253,6 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_cfg_hw; } - mutex_init(&adapter->vport_init_lock); - mutex_init(&adapter->vport_cfg_lock); - mutex_init(&adapter->vector_lock); - mutex_init(&adapter->queue_lock); - mutex_init(&adapter->vc_buf_lock); - - INIT_DELAYED_WORK(&adapter->init_task, idpf_init_task); - INIT_DELAYED_WORK(&adapter->serv_task, idpf_service_task); - INIT_DELAYED_WORK(&adapter->mbx_task, idpf_mbx_task); - INIT_DELAYED_WORK(&adapter->stats_task, idpf_statistics_task); - INIT_DELAYED_WORK(&adapter->vc_event_task, idpf_vc_event_task); - adapter->dev_ops.reg_ops.reset_reg_init(adapter); set_bit(IDPF_HR_DRV_LOAD, adapter->flags); queue_delayed_work(adapter->vc_event_wq, &adapter->vc_event_task,