From patchwork Tue Sep 22 01:35:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2309380 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=n2LXCn3S; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DmC1TmJv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4hpyj470crz1y24 for ; Tue, 22 Sep 2026 21:36:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 507946077A; Tue, 22 Sep 2026 11:36:07 +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 1Q3xlGVSYISC; Tue, 22 Sep 2026 11:36:04 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org CCE3B6076F Authentication-Results: smtp3.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=1790076964; b=D0MHeujRsMb169zCxT7ZujQ83PCvzCebr9WrsjX/hpGBIi49zYWoiFHaYnXcwxPMgxnc FMfJoUe/fKj9SQ5DdkSB1rzqi2VV0fJo5l1uGC+T+04AKtbW9kmzd9UMbEhMq40XFj9Mp dbSIiZCwKmMl2fLY0/+D7qefnnYzjU57UeOe+b5cQNaAXdvYY7fco3YNIyweKE0bOdWq6 P1CCa6h9NC0wuJ1CXlqmINr2F4YLvubG8bi2kjLSMbLgzp3Y9E1iawf0bhJ06bjqO3dB+ bp+I3ZGar+IAaC6boM5LSNRXFEP5U5OoB+fn0YrxasRhzvvP8z3Ul3QYrOACkbsonMw== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076964; 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=yWAgkfKSmqt545gitMXZ8a7jbtkEUIJ7ZnP73mjZcPk=; b=h01IjJtc+QT7b3V5882Cmq7x+OViBwAUFr5joyj4JMs5DfemXg7PdXTQGpUwc24+LsOA iBvl7G9YJe8a8gPjZWGivAnKJ0yNSI4wAWHA+3n8795A85wLnNbLYciGHnLnEZ8BIU+my VUpaLcBszXfGK23gWecbKn5Lip+lqQYsFDzvOlqsHLaJNMZxay+ZQ6Qy634uExyeYvjeN Mj6g5SgK8t482DotORnNI8IM/VIaI2efzGe+m/L6qU5ojFHr3ap6XO9sTC0vFlw7or1eB EqjYlHxW0nEuuE67fsMFK2ipKqWq3Veah8Yq7fk34IrRh9q3a6/YZRv4dazVJ7uARtQ== ARC-Authentication-Results: i=2; smtp3.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=1790076964; bh=yWAgkfKSmqt545gitMXZ8a7jbtkEUIJ7ZnP73mjZcPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n2LXCn3SdNiSwBcdTSrPcG0MzqEjue6SfXJJxlSvfz/iZukK9g04YPgc+9DDkXksf VO9BdkXZ4LwKWO0D08HxEGScOJB50J8H3l+/TmK7Nfj+dSgYRihhXYiWlaubtwCRYo Ndf/wwoNLgs8DPCYRtGPQOClU7dNEDo7NKZqdaZivSq5ws2RR4J/q4mmOtRTFDrZzI KYmba2MsDJjHGPplYEgcBnpsNQO1Tkl6cALHK8R6ohJVN631QyHhxTwCMhq8vn5R54 fdDGlQDUvYiKcIDeH/JKXr9G1qdabJ3GJV8osDibJkPVlyE6oC7nGwDT7aMsoARgr+ Q1xNsHXj8AOMg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id CCE3B6076F; Tue, 22 Sep 2026 11:36:04 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id 52BF3A20 for ; Tue, 22 Sep 2026 11:36:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4441C80C53 for ; Tue, 22 Sep 2026 11:36:02 +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 UVYB_pMAIbWQ for ; Tue, 22 Sep 2026 11:36:01 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 23EB980C50 Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790076961; b=Wco7vfOBng6ZoNAi+CrLQtMwAomdreDOZNjXY9rOC6vDoL3PrfA29XC7rXWT1xpDX3od /iLMTGHuTwgad0lpBiB8IH6s+FxLUhPOHp0E0g77BV4kibZvxezyVJEQKUQfeffE81IXf panA/iS+DOJi4fL/YEQ6HvVCPPiH0WfGK8Gpgo/7OctDcJS4ZmDiJhbjMdwon5kR2B/3G 9qe1tvc7x0lbJuFGchFbcLwW8MGyxgZuJZ9iZR7w6mCGwE/35GyA1auKx2ougWmylBnlv EjhozlvT4WPyXldtjSKTQw9/LgpT/GCnUOlvj0X/to4O+dwrMu2jAB23B+Xn6USlxOg== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076961; 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=yWAgkfKSmqt545gitMXZ8a7jbtkEUIJ7ZnP73mjZcPk=; b=NdLuk4+n5LERtCtB4ka7Ue5uDu9dY3FCRmp0Z+Y8IfiKJEm3km1nSJ9JaYohRs3D4NVM A2pMGY5s3JBiHJa+13BZURZC5w6Idh0cs8Wa4IjJ9b/UdxfCrNZvhdaCBpcCUOOEXJyss VA3s4mTKtyjnC5dyxT4dDdCL/WM0RckG71RoZK7jJqzRjomUehrMEzx0Nu/8iBYlD06e3 I60QnBKYsarapQli9MsSMzF1kwfC+OLkHb6o8ro9UaQRizrKP5qVh2XXT3m16wJY/k5r6 wtP26vqhx+8ye8AzWIc4DGMCkYs/b0r+wrGIGWbX2xX4Cis0/7LA089HBesKB8L0Jpw== ARC-Authentication-Results: i=1; smtp1.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=DmC1TmJv; arc=none smtp.remote-ip=192.198.163.15 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=192.198.163.15; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DmC1TmJv Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by smtp1.osuosl.org (Postfix) with ESMTPS id 23EB980C50 for ; Tue, 22 Sep 2026 11:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790076961; x=1821612961; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YV8sRZ8xJN1n8liM5c8kSZBGA4H9ljZpQrKkF+6r8fc=; b=DmC1TmJv6RxrHsW4H5Eh1nIFqRHYcrmX6unUYoTJX+0mkCMNC3YKVWCk h0/EisKX9QR9sCU2aJSppAPDXAETuSLYtGnkFaxbIaK/gqtzxPGOriZbh MstkYAVok+44YFY99AyaaOgLj1SUMywNninI5K5fAfsuZwKrtp5h3pD92 JKyWtVu526kcBInYLKfgh9paOCE/fvTEaNRldY+DwcjLa6FM0Zsgvyxnz MWC5pnrBrIV1ku0QQoLeoE3uc5rIzFTRzJ027fjDauAsURXpwW7FNyuX7 ZgjJVJk/A1GgTHOaARPCgstD0lPP57AJdgLZcmqWjck+tFClojQfxIfuo g==; X-CSE-ConnectionGUID: fNPHwegnRISjmbSjg7VKwA== X-CSE-MsgGUID: E11U2k4aSYuSvBoU/6FvEg== X-IronPort-AV: E=McAfee;i="6800,10657,11912"; a="90787331" X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="90787331" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2026 04:36:00 -0700 X-CSE-ConnectionGUID: +jcLnOB9RoGTJrGbT9cR8g== X-CSE-MsgGUID: 28vyYbmsT4a3niy0kSLn4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="272591981" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by fmviesa007.fm.intel.com with ESMTP; 22 Sep 2026 04:36:00 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v2 1/4] ixgbe: Refactor device operations to check whether netdev is available Date: Tue, 22 Sep 2026 11:35:55 +0000 Message-ID: <20260922113558.2288111-2-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260922113558.2288111-1-sergey.temerkhanov@intel.com> References: <20260922113558.2288111-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 Refactor several ixgbe driver operations to check whether the netdev they operate on is enabled. This will allow the system to get synchronized, for example, during the PCI resets. Fixes: f7f37e7ff2b9 ("ixgbe: handle close/suspend race with netif_device_detach/present") Signed-off-by: Sergey Temerkhanov Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 5 +++ .../net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 13 +++++- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 34 +++++++++------ drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 29 +++++++++---- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h | 1 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 42 +++++++++++++++++-- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +- 7 files changed, 101 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index a5304390f975..bac3b85a1d63 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -955,6 +955,11 @@ extern char ixgbe_driver_name[]; extern char ixgbe_default_device_descr[]; #endif /* IXGBE_FCOE */ +static inline bool ixgbe_netif_running(struct net_device *netdev) +{ + return netif_running(netdev) && netif_device_present(netdev); +} + int ixgbe_open(struct net_device *netdev); int ixgbe_close(struct net_device *netdev); void ixgbe_up(struct ixgbe_adapter *adapter); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c index 382d097e4b11..4420d3c32996 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c @@ -277,17 +277,23 @@ static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, static void ixgbe_dcbnl_devreset(struct net_device *dev) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(dev); + bool running; + + if (!netif_device_present(dev)) + return; + + running = netif_running(dev); while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) usleep_range(1000, 2000); - if (netif_running(dev)) + if (running) dev->netdev_ops->ndo_stop(dev); ixgbe_clear_interrupt_scheme(adapter); ixgbe_init_interrupt_scheme(adapter); - if (netif_running(dev)) + if (running) dev->netdev_ops->ndo_open(dev); clear_bit(__IXGBE_RESETTING, &adapter->state); @@ -515,6 +521,9 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev, if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) return -EINVAL; + if (!netif_device_present(dev)) + return -ENETDOWN; + if (!adapter->ixgbe_ieee_ets) { adapter->ixgbe_ieee_ets = kmalloc_obj(struct ieee_ets); if (!adapter->ixgbe_ieee_ets) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 1e1db8435506..f6258d1276e3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -468,6 +468,9 @@ static int ixgbe_set_link_ksettings(struct net_device *netdev, u32 advertised, old; int err = 0; + if (!netif_device_present(netdev)) + return -ENETDOWN; + if ((hw->phy.media_type == ixgbe_media_type_copper) || (hw->phy.multispeed_fiber)) { /* @@ -578,9 +581,9 @@ static void ixgbe_set_pauseparam_finalize(struct net_device *netdev, /* If the thing changed then we'll update and use new autoneg. */ if (memcmp(fc, &hw->fc, sizeof(*fc))) { hw->fc = *fc; - if (netif_running(netdev)) + if (ixgbe_netif_running(netdev)) ixgbe_reinit_locked(adapter); - else + else if (netif_device_present(netdev)) ixgbe_reset(adapter); } } @@ -1268,7 +1271,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) usleep_range(1000, 2000); - if (!netif_running(adapter->netdev)) { + if (!ixgbe_netif_running(adapter->netdev)) { for (i = 0; i < adapter->num_tx_queues; i++) adapter->tx_ring[i]->count = new_tx_count; for (i = 0; i < adapter->num_xdp_queues; i++) @@ -2251,10 +2254,11 @@ static void ixgbe_diag_test(struct net_device *netdev, struct ethtool_test *eth_test, u64 *data) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev); - bool if_running = netif_running(netdev); + bool if_running = ixgbe_netif_running(netdev); - if (ixgbe_removed(adapter->hw.hw_addr)) { - e_err(hw, "Adapter removed - test blocked\n"); + if (ixgbe_removed(adapter->hw.hw_addr) || + !netif_device_present(netdev)) { + e_err(hw, "Adapter removed or detached - test blocked\n"); data[0] = 1; data[1] = 1; data[2] = 1; @@ -2468,7 +2472,7 @@ static int ixgbe_nway_reset(struct net_device *netdev) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev); - if (netif_running(netdev)) + if (ixgbe_netif_running(netdev)) ixgbe_reinit_locked(adapter); return 0; @@ -2652,7 +2656,8 @@ static int ixgbe_set_coalesce(struct net_device *netdev, else /* rx only or mixed */ q_vector->itr = rx_itr_param; - ixgbe_write_eitr(q_vector); + if (netif_device_present(netdev)) + ixgbe_write_eitr(q_vector); } /* @@ -3696,6 +3701,9 @@ static int ixgbe_set_eee_e610(struct net_device *netdev, kedata->eee_enabled) return -EOPNOTSUPP; + if (!netif_device_present(netdev)) + return -ENETDOWN; + hw->phy.eee_speeds_advertised = kedata->eee_enabled ? hw->phy.eee_speeds_supported : 0; @@ -3711,9 +3719,9 @@ static int ixgbe_set_eee_e610(struct net_device *netdev, else adapter->flags2 &= ~IXGBE_FLAG2_EEE_ENABLED; - if (netif_running(netdev)) + if (ixgbe_netif_running(netdev)) ixgbe_reinit_locked(adapter); - else + else if (netif_device_present(netdev)) ixgbe_reset(adapter); return 0; @@ -3795,9 +3803,9 @@ static int ixgbe_set_eee(struct net_device *netdev, struct ethtool_keee *edata) } /* reset link */ - if (netif_running(netdev)) + if (ixgbe_netif_running(netdev)) ixgbe_reinit_locked(adapter); - else + else if (netif_device_present(netdev)) ixgbe_reset(adapter); return 0; @@ -3879,7 +3887,7 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags) adapter->flags2 = flags2; /* reset interface to repopulate queues */ - if (netif_running(netdev)) + if (ixgbe_netif_running(netdev)) ixgbe_reinit_locked(adapter); } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 011fda9c6193..54d8b079ada4 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -830,27 +830,34 @@ static void ixgbe_fcoe_ddp_disable(struct ixgbe_adapter *adapter) * * Turns on FCoE offload feature in 82599. * - * Returns : 0 indicates success or -EINVAL on failure + * Returns: 0 on success or a negative error code on failure */ int ixgbe_fcoe_enable(struct net_device *netdev) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev); struct ixgbe_fcoe *fcoe = &adapter->fcoe; + bool running; + /* libfcoe calls ndo_fcoe_disable() even when this callback fails. */ atomic_inc(&fcoe->refcnt); + if (!netif_device_present(netdev)) + return -ENETDOWN; + if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) return -EINVAL; if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) return -EINVAL; + running = netif_running(netdev); + e_info(drv, "Enabling FCoE offload features.\n"); if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) e_warn(probe, "Enabling FCoE on PF will disable legacy VFs\n"); - if (netif_running(netdev)) + if (running) netdev->netdev_ops->ndo_stop(netdev); /* Allocate per CPU memory to track DDP pools */ @@ -864,8 +871,9 @@ int ixgbe_fcoe_enable(struct net_device *netdev) /* release existing queues and reallocate them */ ixgbe_clear_interrupt_scheme(adapter); ixgbe_init_interrupt_scheme(adapter); + adapter->fcoe.reinit_pending = false; - if (netif_running(netdev)) + if (running) netdev->netdev_ops->ndo_open(netdev); return 0; @@ -882,6 +890,7 @@ int ixgbe_fcoe_enable(struct net_device *netdev) int ixgbe_fcoe_disable(struct net_device *netdev) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev); + bool running; if (!atomic_dec_and_test(&adapter->fcoe.refcnt)) return -EINVAL; @@ -889,8 +898,10 @@ int ixgbe_fcoe_disable(struct net_device *netdev) if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) return -EINVAL; + running = ixgbe_netif_running(netdev); + e_info(drv, "Disabling FCoE offload features.\n"); - if (netif_running(netdev)) + if (running) netdev->netdev_ops->ndo_stop(netdev); /* Free per CPU memory to track DDP pools */ @@ -903,10 +914,14 @@ int ixgbe_fcoe_disable(struct net_device *netdev) netdev_features_change(netdev); /* release existing queues and reallocate them */ - ixgbe_clear_interrupt_scheme(adapter); - ixgbe_init_interrupt_scheme(adapter); + if (netif_device_present(netdev)) { + ixgbe_clear_interrupt_scheme(adapter); + ixgbe_init_interrupt_scheme(adapter); + } else { + adapter->fcoe.reinit_pending = true; + } - if (netif_running(netdev)) + if (running) netdev->netdev_ops->ndo_open(netdev); return 0; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h index 724f5382329f..81de590268cc 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h @@ -58,6 +58,7 @@ struct ixgbe_fcoe { dma_addr_t extra_ddp_buffer_dma; unsigned long mode; u8 up; + bool reinit_pending; }; #endif /* _IXGBE_FCOE_H */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index a219590b3118..1f23a035a90b 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -182,6 +182,7 @@ EXPORT_SYMBOL(ixgbe_xdp_locking_key); static struct workqueue_struct *ixgbe_wq; static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev); +static int ixgbe_rebuild_fcoe_queues(struct ixgbe_adapter *adapter); static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter *); static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *); static void ixgbe_watchdog_update_link(struct ixgbe_adapter *); @@ -7395,7 +7396,7 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu) /* must set new MTU before calling down or up */ WRITE_ONCE(netdev->mtu, new_mtu); - if (netif_running(netdev)) + if (ixgbe_netif_running(netdev)) ixgbe_reinit_locked(adapter); return 0; @@ -7423,6 +7424,10 @@ int ixgbe_open(struct net_device *netdev) if (test_bit(__IXGBE_TESTING, &adapter->state)) return -EBUSY; + err = ixgbe_rebuild_fcoe_queues(adapter); + if (err) + return err; + netif_carrier_off(netdev); /* allocate transmit descriptors */ @@ -12345,6 +12350,24 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev) return result; } +static int ixgbe_rebuild_fcoe_queues(struct ixgbe_adapter *adapter) +{ +#ifdef IXGBE_FCOE + int err; + + if (!adapter->fcoe.reinit_pending) + return 0; + + ixgbe_clear_interrupt_scheme(adapter); + err = ixgbe_init_interrupt_scheme(adapter); + if (err) + return err; + + adapter->fcoe.reinit_pending = false; +#endif + return 0; +} + /** * ixgbe_io_resume - called when traffic can start flowing again. * @pdev: Pointer to PCI device @@ -12356,6 +12379,8 @@ static void ixgbe_io_resume(struct pci_dev *pdev) { struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); struct net_device *netdev = adapter->netdev; + bool running; + int err; #ifdef CONFIG_PCI_IOV if (adapter->vferr_refcount) { @@ -12366,8 +12391,19 @@ static void ixgbe_io_resume(struct pci_dev *pdev) #endif rtnl_lock(); - if (netif_running(netdev)) - ixgbe_open(netdev); + running = netif_running(netdev); + err = ixgbe_rebuild_fcoe_queues(adapter); + if (err) + e_dev_err("Cannot rebuild queue layout after PCI error recovery: %d\n", + err); + if (running && !err) { + err = ixgbe_open(netdev); + if (err) + e_dev_err("Cannot re-open netdev after PCI error recovery: %d\n", + err); + } + if (err && running) + dev_close(netdev); netif_device_attach(netdev); rtnl_unlock(); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c index 89f96c463f02..02820982b202 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c @@ -39,7 +39,7 @@ static int ixgbe_xsk_pool_enable(struct ixgbe_adapter *adapter, if (err) return err; - if_running = netif_running(adapter->netdev) && + if_running = ixgbe_netif_running(adapter->netdev) && ixgbe_enabled_xdp_adapter(adapter); if (if_running) @@ -71,7 +71,7 @@ static int ixgbe_xsk_pool_disable(struct ixgbe_adapter *adapter, u16 qid) if (!pool) return -EINVAL; - if_running = netif_running(adapter->netdev) && + if_running = ixgbe_netif_running(adapter->netdev) && ixgbe_enabled_xdp_adapter(adapter); if (if_running) From patchwork Tue Sep 22 01:35:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2309379 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=initRNYy; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Bps4lsAw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4hpyj46095z1xqn for ; Tue, 22 Sep 2026 21:36:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 217A960796; Tue, 22 Sep 2026 11:36:07 +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 qzNpBinUQwV8; Tue, 22 Sep 2026 11:36:05 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org A209560780 Authentication-Results: smtp3.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=1790076965; b=ZlDBUnhI4bnJxwSDyunAWOBNl8xy/svdghRsrSjdw3GFpFZnSCqGMM2ZR5cXtnNwuMkL 0FmlC4LGZHe4jE30OYStPENqZWe9Q/1l9Hk2nZcYwZv/8gZaHbGniFj8rW/VSED8rtTcC eXun8qf9tnQVbTCZfN9shS4c9+QJRZ84MECweLcat+clO989ZEz+KFZX6DX+a7rqwKDke eShYQGWCUv7C/btrqzmEvDH9iEw6lcealSPlvjasO9c47OlAeNlusJNUxrQviaf13yfGM 3yqVQIPuYXTcjodg2TO7+E/3lti8VeFt+hSHQl+o/WV5Ubw9+89nzWqX7WRmnYIPVQA== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076965; 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=JqetkN7V+Go1GbZVm60LW04hQbgf7zJheygUQQka3OU=; b=G4G+ioOGzOBN9jrgWAAn51Rn8WiFPVLN0DX7BIYd7V6VEDYsGYISSBKA4Woz78+raZpe 583ymvCHT1563R5hdqCcLOJotjIN3OJqwJsJd05U9uszFNZTOb2Lo337iniDTe+YapMhs 1JL2q3UJN00fSNlxxBJ6kHOctMQC5rchotyuh+/T19eK4eFdxRei6GX+nwCJ06MYDN/XV +SJWIBZgDlfwtpBdavIn37rGgFyThUfIj5HtsE6cJA7ttpoDj+7DafLSQCeen9XNLcC3E kuSE43evow/pzB3NZHs9A1URXyP+Upvd8hRQ8euJXUGwCdjPXtXHFjq40NbWC8OkcDA== ARC-Authentication-Results: i=2; smtp3.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=1790076965; bh=JqetkN7V+Go1GbZVm60LW04hQbgf7zJheygUQQka3OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=initRNYye6lzsV/ibHoulGPEpdi6PVeO82zuk/o1QAmy0PmgHzIe//amkt43xJ25w 9YWILBB8syQhuUrlnjkdYW6BmcoSvX7RTz93bk6o5vYaSbvzYdyxIpDb635bXohwWe brj5/xpDN/youQptcIzyZpJQLBFmBVOMwpcr/Bnf1Ek4W1tTnHNXc2z4gCZm/+zPFW q6xJe5X0H8edNIffRR8KkPxeYcUMCH53l6H6YbGIlq4rsHtd/yej71ZOMIPJiEj7T3 yCvI/xD4JfGItdA+Nf2fGSLkXnkMgs18SCc0JnIfpHA9QktfGCTgwVgllAPKpglZ7v r2VSLnmV8eLcA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id A209560780; Tue, 22 Sep 2026 11:36:05 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id B555735A for ; Tue, 22 Sep 2026 11:36:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9BBC780C50 for ; Tue, 22 Sep 2026 11:36:02 +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 mC02NPBHxsUt for ; Tue, 22 Sep 2026 11:36:02 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org E418280C4E Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790076962; b=Ro1OGkdsnV79hVgSXnHTFYWTt67LaWR1rvDS8kN6TAh5ppRq0kI0posN+J+eTscCDUWV FxXpLOs1BewtIyOqqqqz1q0vM32XpRJyX9kFESgiVSk68qyNjEJeC8VDaJnIM0y4UMGfP VECi/JeLEktPpWN4YB3IXl/1ZFHer6J31YHjM7IMd/A79+Ebd9WUnjrxpKCXLbUptDqIY UpLt9PG7JQRkXqolntE0/idahyyphZyJquIrRO9o+qLasv9LvvyXn8WqwvXyW/f5jBuQr F+yNdsYsxc+aWb3ouyUgCBWwQqQ0N1Ui5jKcZQeugvcdtDlutUrwzkuKFZjFc+3Cw4A== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076962; 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=JqetkN7V+Go1GbZVm60LW04hQbgf7zJheygUQQka3OU=; b=EvXcEPWe20zVGO1etiL/MKwu7ThQvKnBfp3motIjYq2IG9rUd8cRlCj+qN4IasVL82Z4 7umq5bV6/8al3q5N20SoiGON8hiKhSkHb895/HQFPmlNPUvvkFugElfpnuxY7hOQ8Ec/o ct3XzaBMZeVrw8YM22uZWuIBfq7PUjAVauD2k/QuvdOVxt6xi3YeC2jC9rIPu9qiS1dLi g4lS2CdLTlo879xn7wi9jcEG39dSuObDHXtqjD9PvWnv2XDkMhA8xwdphUJcor6hN3d2d WP2IroxR0n6TVCUp0O57hNLgoI6CPUC6KhTYP0D42DW1mgHiGdjlLb1lkjNWUfKEdaQ== ARC-Authentication-Results: i=1; smtp1.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=Bps4lsAw; arc=none smtp.remote-ip=192.198.163.15 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=192.198.163.15; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Bps4lsAw Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by smtp1.osuosl.org (Postfix) with ESMTPS id E418280C4E for ; Tue, 22 Sep 2026 11:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790076961; x=1821612961; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EKdSAYxXzsS0D7//wmgMkbjn8Kk+YYSMLuL1v0Aqp4c=; b=Bps4lsAw1BBjcBobuXORGhdcvrcOxJ5ydsp11FWXloKIJyiB5RBlVBqP TG3fO19DBDkhzn8HB+HY+EqT6oyeWPoHS0v+dzmRp0/slBfMQdFz6QIe8 COui8RxAIQ0uu32pEJrKKFPTy2N09hC6Wfi4zugrs+tRcWVEIckyALA0r WbM1PrXwc/eBqWT9BYmOoTBYBTo1FG+9fJdXry99CGcMERH8hAhP3Nvcf UMtAbCnHyTEHYbVRiG4jPz8KwKODxJBwAM2bnzJGNntmvIcn1V1qbVE4h 84AzM62d826C587Lx5zwNHx/99ocaehck4MZwtG5bqERWwVRmu653wWX/ A==; X-CSE-ConnectionGUID: xlDun/ZoTRC25P+hH7SSvQ== X-CSE-MsgGUID: hTrSXHLLSra+we3RU1qAVA== X-IronPort-AV: E=McAfee;i="6800,10657,11912"; a="90787334" X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="90787334" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2026 04:36:01 -0700 X-CSE-ConnectionGUID: K4nx68ibT6OMcZfrQaMv9Q== X-CSE-MsgGUID: +Ue86OZIRBSouRcLo686Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="272591993" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by fmviesa007.fm.intel.com with ESMTP; 22 Sep 2026 04:36:01 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v2 2/4] ixgbe: Fix FCoE refcount taking for unsupported adapters Date: Tue, 22 Sep 2026 11:35:56 +0000 Message-ID: <20260922113558.2288111-3-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260922113558.2288111-1-sergey.temerkhanov@intel.com> References: <20260922113558.2288111-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 ixgbe_fcoe_enable() increments the FCoE reference count before checking whether the device supports FCoE. The unsupported adapters shall not take a reference while the ones which have FCoE already enabled only need to skip hardware initialization. Fixes: 27ab76065c0c ("ixgbe: add a refcnt when turning on/off FCoE offload capability") Signed-off-by: Sergey Temerkhanov Reviewed-by: Simon Horman --- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 54d8b079ada4..6585af527743 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -838,15 +838,21 @@ int ixgbe_fcoe_enable(struct net_device *netdev) struct ixgbe_fcoe *fcoe = &adapter->fcoe; bool running; + /* Unsupported adapters do not take a reference */ + if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) + return -EINVAL; + /* libfcoe calls ndo_fcoe_disable() even when this callback fails. */ atomic_inc(&fcoe->refcnt); if (!netif_device_present(netdev)) return -ENETDOWN; - if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) - return -EINVAL; - + /* If offload is enabled, only skip HW init, but keep the reference. + * ixgbe_fcoe_disable() decreases the refcount for this case and only + * disables the offload when the refcount reaches 0. This handles the case + * where multiple offload interfaces are enabled on the same PF (e.g. VLANs) + */ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) return -EINVAL; @@ -892,6 +898,9 @@ int ixgbe_fcoe_disable(struct net_device *netdev) struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev); bool running; + if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) + return -EINVAL; + if (!atomic_dec_and_test(&adapter->fcoe.refcnt)) return -EINVAL; From patchwork Tue Sep 22 01:35:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2309381 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=h02HtPcy; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=N4OK6YYd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4hpyj51wNYz1yVN for ; Tue, 22 Sep 2026 21:36:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E361F605F9; Tue, 22 Sep 2026 11:36:07 +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 GIQSb1SA1rrR; Tue, 22 Sep 2026 11:36:07 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org 1D31160762 Authentication-Results: smtp3.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=1790076967; b=n4q+4tROK8//Gmiysguvf3AZ63U3uk4KB6EmyAxPSfGVbrJE7rFHzdycAt8W3WA0fxTh 1p0i4xLnS75mM6uWg7uVfMK4zlR/I0Z2zFlhm7J1mjSEli5mSM4+isPZBGGzJApN0o1ZX RZSKErBddZ/osHDBLxjsOd7ty0rWwD+AdMqGpeTgb+5SRcbhFqjwzPGRKqAaLwhzPbWIY 6DH8uV/BcomLSlNiV6apZMHgPL4JnGNpXwIwqmXUoPxnX1repUigKo76w4fm+Xzy1xNWA iZsKm9UMMI2qTNDKMUt9J2xtgXE6o1YdNvZhZOm8W2K76Li0UfPmMr5hC9Mx8kCH7cw== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076967; 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=YQGntyncCE6Ts827BbErJg68ZnMr2DBjecynMPRpXWY=; b=FIk61kaCLbkgaMk7sfUsSUzm/QA9IYLKUeEroeUJ11R3eINGMT5+vGfWOl0+jhVhoMMZ ipi1GVDiO0VFZ2h3AbsL8oDZ8vpvV0g41O4pXqmbCi15aRgAgdbavpIjCLKnURWBSf7Nr tG01SS51e7oaVGjqBp4lzi6m7MLF+s8acUo2Hw57RQnT78hCcrksK3MCWtjh0/lQB5zeZ 7q1aw6GP+yuc79bBxCe5Q1HbcV7plONYPmS42BtNv+MJ8Ms1cSDvGh8Z3mJl5Dtwi3siS 2GDMqBP/SEOgt1lPSgi3/Xwajthkmkb5Pue4wVBY6/VBMWPWAlxfhp1EPyzU2AfzhZg== ARC-Authentication-Results: i=2; smtp3.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=1790076967; bh=YQGntyncCE6Ts827BbErJg68ZnMr2DBjecynMPRpXWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=h02HtPcy0Mr2zc3aGPWOxZ/aNFw59rLAdZNC0zCiE7StfS/HyQptc2bHxvOepNvPA 5WNG0XWVW98ER7nW5eL0W4HHpnuNs0a3tuZ30q0FgFj+2xa2z0FFZ9NIM9dBOiYXxL r7ctVULPtaX2xwYNQndFX4tVFymo+GVSNoEr1a/h+/cTMS4FprHUUPIJPHKOv56wze +s2iB3mOxjYlE0CG14d/33K1k1YX0lc6WybUWyJW5ixzrFcDsACFGHahU73nlzp3Ig YpqxRYE0feCMeqpZScffaewSvWEmI+qBzYPls+hQNn/ggtqdCc53YjUb973/UYJwJQ +1oc6Ss0ocN9w== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 1D31160762; Tue, 22 Sep 2026 11:36:07 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id D40EBA20 for ; Tue, 22 Sep 2026 11:36:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id BA3F880C50 for ; Tue, 22 Sep 2026 11:36:03 +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 4SjVxG_0h0sG for ; Tue, 22 Sep 2026 11:36:03 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 0052680C4E Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790076963; b=rEOmQjcy95L7tfGW0+1y3RC8G1CnWh6twUQVQk8FIHznRq0+NmIHR/9Dtyds21Wvvb9/ SaccAocyTJQZ/qWJndWESR+S8CCHvs9mr7wDVQcaVv+sCNyNBBXf5E4R/ltRkcYB4t/p6 nzIrKuAdOKe63tJwE6uVmHazuOb4cAMmdYpJBG4lxDqSGCCmJy49yHlNoeSpZMWTiGFOw QLWToVMqEF2bZC6FljeLQ8enOOPd9QcdwPcQ463uLO+NeiQp+PI980DGx3t2Wm52xvwjG rxh/NfmVQTpmTtVG6kp12SOwRbCB4vNs9HK/fN/BdYyLbr0VhwquAt1DuAVEPgcYfFw== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076963; 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=YQGntyncCE6Ts827BbErJg68ZnMr2DBjecynMPRpXWY=; b=iuk3vQXzcS4ZcwxzLWmNW+tjileWEpoHaXb02Byc7svU4vxb9fulqTk6ZLDiEQMdsHTM YeLTgD/RNx+6c2b8mTgsoQ07qxgK0wFIo/DHKu6ZnZbzYFGIjZo4XujK3466G1wVcb48n kTBsViA0YX39ITFaKK4T4GqEAGt0od+kxV9AFLHLLXRjQxbN0AU9hqL6nJeIAGJrzUAx1 9yLz/QnNkEEfAk0YhLdTB6lsHjuC4dywMElvky4moYpfObgpcg/hWOuCvAkTbcC+mxhYi zDX9nRUFwB6JvL/bPnS0djH6GGeDV3EXUJ986M50duz2VorsehTry9Ac5GJnWBDtQyA== ARC-Authentication-Results: i=1; smtp1.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=N4OK6YYd; arc=none smtp.remote-ip=192.198.163.15 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=192.198.163.15; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=N4OK6YYd Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0052680C4E for ; Tue, 22 Sep 2026 11:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790076963; x=1821612963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0oxY2IqGDY/2V7icmio8r/7J85s/Evd99fGLb1HfZ/k=; b=N4OK6YYdFFTyu6qDTmBGFRx1W7TuIX0/vjro7vKXKcnUJqb6Q0jVPbck JNd5oBR1vxT1XZpFA2+QfKKQL1CoytwMZclptlQm0o5L0+yqQPLbJtGmy kNH2Wf7fHXZCic1DW0XrWk+zP5n5p6KBrSwbG22D+hRW4SmZvwYsUzd+R 5k+xoEJ2TiZOL8YFzO67ETZPtq0QbxjmL0vdYbpge1N6n6e7RCBRJJ2S3 4shX0+z1YWFie3ZwWgk5+OcZv/xcHrrzhHwAr3mYSB6rwVkR5zBRvSiqd ShoyCz45ugzsfMsECFSYJIz6bKKn5JIOsj+tdyqJuXRWersaj+WoiR+HI g==; X-CSE-ConnectionGUID: b7cUrL7xQASqJFT+bT5tEQ== X-CSE-MsgGUID: KyXJVEa4QSmL+nXJprOdaQ== X-IronPort-AV: E=McAfee;i="6800,10657,11912"; a="90787337" X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="90787337" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2026 04:36:02 -0700 X-CSE-ConnectionGUID: n76H0qB8S6asiwsFcamHDQ== X-CSE-MsgGUID: 9X/MHD//TvuXvEuRHV/vsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="272591995" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by fmviesa007.fm.intel.com with ESMTP; 22 Sep 2026 04:36:02 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v2 3/4] ixgbe: Restore previous XDP program on ixgbe_setup_tc() failure Date: Tue, 22 Sep 2026 11:35:57 +0000 Message-ID: <20260922113558.2288111-4-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260922113558.2288111-1-sergey.temerkhanov@intel.com> References: <20260922113558.2288111-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 When enabling or disabling an XDP program requires a queue reconfiguration, ixgbe_xdp_setup() swaps in the new program with xchg() before calling ixgbe_setup_tc(). If ixgbe_setup_tc() fails, the adapter was left pointing at the new program even though the reconfiguration did not complete, leaking the reference to the old program and leaving inconsistent state. ixgbe_setup_tc() may have already reconfigured the queues for the new program before failing. The XDP ring layout then no longer matches the previous program, for example when removing a program has removed the XDP TX rings. Restore the previous program and rebuild the queues for it so adapter->xdp_prog remains consistent with the ring configuration. Otherwise, a later open could run XDP without XDP TX rings and dereference a NULL ring. ixgbe_setup_tc() handles the device having been left down by the failed reconfiguration. Fixes: 3fe1d0a48d21 ("ixgbe: XDP: fix checker warning from rcu pointer") Signed-off-by: Sergey Temerkhanov Reviewed-by: Przemyslaw Korba Reviewed-by: Simon Horman --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 1f23a035a90b..6ef51b822a50 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -7348,6 +7348,25 @@ static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter) ixgbe_free_rx_resources(adapter->rx_ring[i]); } +static bool ixgbe_ring_resources_allocated(struct ixgbe_adapter *adapter) +{ + int i; + + for (i = 0; i < adapter->num_tx_queues; i++) + if (adapter->tx_ring[i] && adapter->tx_ring[i]->desc) + return true; + + for (i = 0; i < adapter->num_xdp_queues; i++) + if (adapter->xdp_ring[i] && adapter->xdp_ring[i]->desc) + return true; + + for (i = 0; i < adapter->num_rx_queues; i++) + if (adapter->rx_ring[i] && adapter->rx_ring[i]->desc) + return true; + + return false; +} + /** * ixgbe_max_xdp_frame_size - returns the maximum allowed frame size for XDP * @adapter: device handle, pointer to adapter @@ -9921,6 +9940,7 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(dev); struct ixgbe_hw *hw = &adapter->hw; + bool running; /* Hardware supports up to 8 traffic classes */ if (tc > adapter->dcb_cfg.num_tcs.pg_tcs) @@ -9933,7 +9953,17 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) * match packet buffer alignment. Unfortunately, the * hardware is not flexible enough to do this dynamically. */ - if (netif_running(dev)) + if (!netif_device_present(dev)) + return -ENETDOWN; + + running = netif_running(dev); + + /* If a previous ixgbe_open() failed, the netdev can still be + * administratively up after IRQs and ring resources have already been + * released. Skip ixgbe_close() only in that state; ixgbe_down() leaves + * resources for ixgbe_close() to release. + */ + if (running && ixgbe_ring_resources_allocated(adapter)) ixgbe_close(dev); else ixgbe_reset(adapter); @@ -10972,8 +11002,14 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) synchronize_rcu(); err = ixgbe_setup_tc(dev, adapter->hw_tcs); - if (err) + if (err) { + xchg(&adapter->xdp_prog, old_prog); + err = ixgbe_setup_tc(dev, adapter->hw_tcs); + /* An ndo_bpf error leaves old_prog attached in the core. */ + if (err) + return err; return -EINVAL; + } if (!prog) xdp_features_clear_redirect_target(dev); } else { From patchwork Tue Sep 22 01:35:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Temerkhanov, Sergey" X-Patchwork-Id: 2309382 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=LxhidI8k; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EjnQodWO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4hpyj62BnXz1xqn for ; Tue, 22 Sep 2026 21:36:10 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EE00A60762; Tue, 22 Sep 2026 11:36:08 +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 UHMcxiSAt-sn; Tue, 22 Sep 2026 11:36:08 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org 242EE6077D Authentication-Results: smtp3.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=1790076968; b=l8iZpx5T9RNCmXQ5Ea4pzQFlub946/xk+9kPhdGudJurv4xKhZoB/ao+OhQrc4HqSHzE eNQ0BSAqJ++UygyGJDwZSv6DncY2zt512AjuUyeOiKtYsUkOMnTgMbbyS0ilHQ0gmqR50 UO7fsJa0dEcwcFP0FrnbxVJ3T875yyIaybhaRJdknHd411reR68rb3HC61/Jb3T8GrtGm QMiGZ0FH2dIflUrpJBma/1p0Zc3yM1elscqT6qUsnGRRMgpk1aI12IwS2Nw3zYEPxHuh4 BzIDLry4RjstBX+9E1sr3XckyOfHpNFDKd9ahJWukj46Ky+6DmDgj+/2VpRIM937o5Q== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076968; 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=INdFd4OCYJfW/GGc2EnSpjoaIgPkwKHlZfRQetW2lSY=; b=jjxss42gnr6xAeYE/K6hrUbpqMRRJPrdyWBhUugP/twoQANwz7wBrnOIk1Wht5nRQSqu 6Xs+d+KfYd5cax8mNoXC8Ubr9LPxnSLPiszt2IVDRL367EiYxivNXR9uQwBEIuuCKrbxF 2xtVY6AcsyJBqOzgmT8+jfgBmAu8wh6u33yRobgLdiIBkdueiYb9vtkpaz4IEifZMozle XrbQ8Q0rA8b8aIfG78Ex4LUpboLPgAjTNxaRHJHvwULn69f5kWXEpzE4uoR25aNHQUt/G n4YyFAqbCxEzwJpp3AKXQ5IdrkHcAXJladX8wAOEU11SIZKDOgIVfza/Jc0xSza3k2A== ARC-Authentication-Results: i=2; smtp3.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=1790076968; bh=INdFd4OCYJfW/GGc2EnSpjoaIgPkwKHlZfRQetW2lSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LxhidI8kzkZ6ynqkAwyXubpMZdfueIIIJPP7RlKPhuofyBWvxxvF84sspqtl5yV9p Wefivd8mbBhppGlNCaHhy3+/h3S+KQNMzhOI/cTNpl/q094uo1Yko2f+GAAfmLOwQ1 ZxTfFn31AdB5ZjVfccgsxAqmFu7ZUg4BT6q3UgROYLzC8NpwPQv08pgXz2TltMOKGE kro6guf/elfnsBZYrAOEgjZfdh/zdn7njl/JDRMDhqDg3O5qAC79e3zer0O37UJdn2 ftn9BtGj2GN21vVNM6x5UORIiW8BQmWpRXrViAOedf4j66V092oM1tIbjHaJ2ojpu0 +qnAM7CmUXvTQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 242EE6077D; Tue, 22 Sep 2026 11:36:08 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id 0ACED35A for ; Tue, 22 Sep 2026 11:36:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E53C380C50 for ; Tue, 22 Sep 2026 11:36:04 +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 6dhTywrFQwL6 for ; Tue, 22 Sep 2026 11:36:04 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 01CB380C4E Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790076964; b=Jfq0yAO0zf2HUvGIuA5ifophAXrnBIgtuC7IxuTkI3F8xLgL3eJlkNxkHx/+x+++z+Bd EtKvwPG+g/Yn3UGKyH0bf470KyjJj18KveWZVlzd6Wk44p/+sDkzMEH8dPvjBuaeYvGOl T4ygaqfRNATNUre45q9Yvad2xB6SnFsEeEyBb98b+HxBCAtxaXBOBrWlaVKw4GU9o9UVr Ou9/iNtlG/tSm4erq1WMr+NGURGKr+wkiEot/57dWJxDROmCQapFPd7no036CAW8/QEH0 bTxnrhqVx93xUO00GAJulql39kqgbuhwOBWx2EUGDuA38O26UK7SeuXm22h6WFuu9CA== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790076964; 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=INdFd4OCYJfW/GGc2EnSpjoaIgPkwKHlZfRQetW2lSY=; b=Z9ToUHUEPqADdERt+8oKUpc9Is6SIbwoR2hMnslPW01SXLXVHdieixNeL/9MrJxwPqXZ EfhOXq2vgIRduWzv0Gg2/afjwsj/EbUHd98YveAoClYQMmt7k/Uvm9XEN0byS1S2Gl+NG rRpw0j6S2uEIyKx0L/XI+WKuIAzUxHxK504mvWkuZVjDdYBHgcE+pasUi68NwWN8C+yAB 2nYHTMxdWoB9cJoRagrJmNNRCCYQtJo7lGVVAPND6y/BmgeMOZEcm7vXQUFpBV1FndH4x XQVCfPK61dRdPi4TRi8oSIunxQRg40DmX9/kdrr4gGoY/TMTTvpQxc7PjJp7MEimj7A== ARC-Authentication-Results: i=1; smtp1.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=EjnQodWO; arc=none smtp.remote-ip=192.198.163.15 Received-SPF: None (mailfrom) identity=mailfrom; client-ip=192.198.163.15; helo=mgamail.intel.com; envelope-from=sergey.temerkhanov@intel.com; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EjnQodWO Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by smtp1.osuosl.org (Postfix) with ESMTPS id 01CB380C4E for ; Tue, 22 Sep 2026 11:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790076964; x=1821612964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4QH1S2syL6mlFcY4Z5eC/lt5lGMSXXdYEQtpCVVQWfo=; b=EjnQodWOj18QaYJ9GS84qtG6E6C6WbJXTFti4++Yg+O3EbRR/i3ZWIZb Ui9hbz444bnzB8oLdSaT3JBsST7iOw+4zA7HeKPWcDevPpD4B8PvORE1t vB4GzyacI5NHuXtXl9nnEgY5Vblaa/12k3JjdQDcz5ryP+Fm7okmx5gnh Bj5TjpKnvnxmft6w9mlfsJkzSSqP1I9LOZC4CaZoCH21Kwmyaa69U2U1S cKPR5Wp10d7GAIqimDTqA8k08Qn//UezNIQ+1xGerF2ENZxs1pqUCu3fP 72PWOqKqr3xgRHONIrkMSO6sa3Rzl1Xnko+rakNnk33LmY8WiQXNhOOnw Q==; X-CSE-ConnectionGUID: xKuCPS7YTLqycfULK5/FEg== X-CSE-MsgGUID: VX7ZCpINQneFsLlW/sMAZQ== X-IronPort-AV: E=McAfee;i="6800,10657,11912"; a="90787339" X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="90787339" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2026 04:36:03 -0700 X-CSE-ConnectionGUID: 16ei8HstTaG/F8VFLERuwA== X-CSE-MsgGUID: 7sCUDdjdRAWIgR05RVZHEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,116,1787036400"; d="scan'208";a="272592003" Received: from gnrd8.igk.intel.com (HELO GNRD8) ([10.123.232.137]) by fmviesa007.fm.intel.com with ESMTP; 22 Sep 2026 04:36:03 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Subject: [PATCH iwl-net v2 4/4] ixgbe: Implement PCI reset handler Date: Tue, 22 Sep 2026 11:35:58 +0000 Message-ID: <20260922113558.2288111-5-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260922113558.2288111-1-sergey.temerkhanov@intel.com> References: <20260922113558.2288111-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 Implement PCI device reset handler to allow the network device to get re-initialized and function after a PCI-level reset. This is necessary for the adapter to avoid TX queue timeouts occurring after the PCI reset is performed via sysfs during its operation. The reset codepath may trigger a number of dependencies in the reset of the driver, so that it is necessary to check if the netdev is present and running there. Fixes: 711d57796f5c ("PCI: expose function reset capability in sysfs") Signed-off-by: Sergey Temerkhanov Reviewed-by: Przemyslaw Korba Reviewed-by: Aleksandr Loktionov Reviewed-by: Simon Horman --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 1 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 111 ++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index bac3b85a1d63..88247e760bda 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -912,6 +912,7 @@ enum ixgbe_state_t { __IXGBE_PTP_TX_IN_PROGRESS, __IXGBE_RESET_REQUESTED, __IXGBE_PHY_INIT_COMPLETE, + __IXGBE_PCI_RESET_PREPARED, }; struct ixgbe_cb { diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 6ef51b822a50..da26d1013f3e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -10537,6 +10537,9 @@ void ixgbe_do_reset(struct net_device *netdev) { struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev); + if (!netif_device_present(netdev)) + return; + if (netif_running(netdev)) ixgbe_reinit_locked(adapter); else @@ -12396,6 +12399,7 @@ static int ixgbe_rebuild_fcoe_queues(struct ixgbe_adapter *adapter) ixgbe_clear_interrupt_scheme(adapter); err = ixgbe_init_interrupt_scheme(adapter); + /* Keep reinit_pending set so ixgbe_open() retries before using queues. */ if (err) return err; @@ -12404,6 +12408,110 @@ static int ixgbe_rebuild_fcoe_queues(struct ixgbe_adapter *adapter) return 0; } +/** + * ixgbe_pci_reset_prepare - called before the pci bus is reset. + * @pdev: Pointer to PCI device + * + * Quiesce the driver in preparation for a PCI function reset. Called from + * pci_dev_save_and_disable() before the core saves config state and writes + * PCI_COMMAND_INTX_DISABLE to clear bus mastering and MMIO decode, so MMIO + * access to the device is still valid here. + */ +static void ixgbe_pci_reset_prepare(struct pci_dev *pdev) +{ + struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); + struct net_device *netdev; + + if (!adapter) + return; + + netdev = adapter->netdev; + + rtnl_lock(); + if (!netif_device_present(netdev)) { + rtnl_unlock(); + return; + } + + set_bit(__IXGBE_PCI_RESET_PREPARED, &adapter->state); + netif_device_detach(netdev); + if (netif_running(netdev)) + ixgbe_close_suspend(adapter); + rtnl_unlock(); + + /* __IXGBE_RESETTING is intentionally not set here: it is spun on + * while holding rtnl by ixgbe_reinit_locked(), ixgbe_dcbnl_devreset() + * and the ethtool reset paths, so holding it across the rtnl drop + * would deadlock those callers against ixgbe_pci_reset_done(), which + * needs to re-acquire rtnl. During the reset window concurrent + * rtnl-holding paths must treat the netdev as detached, while teardown + * paths also observe __IXGBE_DOWN set by ixgbe_down() via + * ixgbe_close_suspend(), matching the existing ixgbe_io_error_detected() + * flow. + */ + + if (test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) { + /* The service timer was already stopped by ixgbe_down() via + * ixgbe_close_suspend(); if the netdev was not running, the + * timer is not armed. Only the currently queued service task + * (if any) still needs to be flushed here. + */ + cancel_work_sync(&adapter->service_task); + clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); + } +} + +/** + * ixgbe_pci_reset_done - called after the pci bus has been reset. + * @pdev: Pointer to PCI device + * + * Re-initialize the device after a PCI function reset. The PCI core has + * already called pci_restore_state() before invoking this callback, so the + * saved Command register (including bus mastering) is back in place. + */ +static void ixgbe_pci_reset_done(struct pci_dev *pdev) +{ + struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); + struct net_device *netdev; + bool running; + int err = 0; + + if (!adapter) + return; + + netdev = adapter->netdev; + + rtnl_lock(); + if (!test_and_clear_bit(__IXGBE_PCI_RESET_PREPARED, &adapter->state)) { + rtnl_unlock(); + return; + } + + adapter->hw.hw_addr = adapter->io_addr; + ixgbe_reset(adapter); + IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); + running = netif_running(netdev); + + err = ixgbe_rebuild_fcoe_queues(adapter); + if (err) + e_dev_err("Cannot rebuild queue layout after PCI reset: %d\n", + err); + if (running && !err) { + err = ixgbe_open(netdev); + if (err) + e_dev_err("Cannot re-open netdev after PCI reset: %d. A new reset is needed.\n", + err); + } + if (err && running) + dev_close(netdev); + /* Restore presence so userspace can retry later. If recovery failed, + * dev_close() cleared IFF_UP first so netif_device_attach() will not wake + * Tx queues without a successful open. + */ + netif_device_attach(netdev); + rtnl_unlock(); +} + /** * ixgbe_io_resume - called when traffic can start flowing again. * @pdev: Pointer to PCI device @@ -12441,6 +12549,7 @@ static void ixgbe_io_resume(struct pci_dev *pdev) if (err && running) dev_close(netdev); + /* A failed running device is down; attach permits a later open retry. */ netif_device_attach(netdev); rtnl_unlock(); } @@ -12449,6 +12558,8 @@ static const struct pci_error_handlers ixgbe_err_handler = { .error_detected = ixgbe_io_error_detected, .slot_reset = ixgbe_io_slot_reset, .resume = ixgbe_io_resume, + .reset_prepare = ixgbe_pci_reset_prepare, + .reset_done = ixgbe_pci_reset_done, }; static DEFINE_SIMPLE_DEV_PM_OPS(ixgbe_pm_ops, ixgbe_suspend, ixgbe_resume);