From patchwork Wed Oct 23 17:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 2001247 X-Patchwork-Delegate: anthony.l.nguyen@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=Dej8Tyiy; 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 4XYbby621dz1xwf for ; Thu, 24 Oct 2024 04:28:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0C6DF608D0; Wed, 23 Oct 2024 17:28:11 +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 SLp9viUai5Av; Wed, 23 Oct 2024 17:28:08 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B3DB0608B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1729704488; bh=XDXXNue6psjylQE85p9KLrQo9I2faybviN6SW/hT9xU=; h=From:To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Dej8TyiyxE6df7qi5Rsf6GPvtsn0GfCi3e7DMU0nJ5XAxajpcQSdGg8bynSkoiYAT bFcH97XIq8vyFIK1/p4sMu4AZNyeXGRNvFRYsCZ/cSSpcYYSFVJ90bWcswm/Xd1InT PhwVJ5uue9UkmCeDau+2JWtjrb7P3ijKpvw0PD6Wc9PVsrx9tLug/3gZD9KC+zkoFn oMnF4TQ9dd5hIjOsCUhblAk752btB+Siw1EUa/i+AjKV+ZrDUfig67tGc+V4VXhPCz YZ/ao/3JT2dY7xWi1oAoOMQ3M4QwZKZHOPgIuxYeazTVYfzypBF7zDWi8nu+lMsaUd wl6Yv4lyIOcXQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id B3DB0608B8; Wed, 23 Oct 2024 17:28:08 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id 47BBB2072 for ; Wed, 23 Oct 2024 17:28:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3394040148 for ; Wed, 23 Oct 2024 17:28:07 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id elMHAXdrWOyM for ; Wed, 23 Oct 2024 17:28:05 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::52c; helo=mail-pg1-x52c.google.com; envelope-from=jdamato@fastly.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 9886640A49 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9886640A49 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9886640A49 for ; Wed, 23 Oct 2024 17:28:05 +0000 (UTC) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-7ed67cfc1fcso14105a12.1 for ; Wed, 23 Oct 2024 10:28:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729704484; x=1730309284; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XDXXNue6psjylQE85p9KLrQo9I2faybviN6SW/hT9xU=; b=Eor/A/CCwQ5AQoRaNIxcABT9ngdGM1i08QASHnyq0IspIVOf77DEkAvP07JR+mXK28 ct1nvraLkd89EEq2TjcpjtWfrlWMx+WWXPJenPRWrQgeNKtrQTv6FCjvQOAHWtmH4HMf qGwS7LvsPI4pFXY+LGKzqSo58prNXq8m/4JVC7wnM3GZpoNl7Z5aB/H8LdtEb2eY3XcN OfbQqXV2e5riURRfiatAoUlEp4vCyMx1Bd+0ug1cU/fK/N9D/xt/fSJNYlpWUIaMH2eV Fz8Psx05x2I0E0G1qWW40E4ZH3OjrG29tT7T52GuYMta5sWoF8pHsCqDBXXAj80YWI7+ ucVA== X-Forwarded-Encrypted: i=1; AJvYcCWJ5im2O2iX58LzriUglnSjDxfA5Y6q24rzS61Gv8o87SPzW790htbOQ3ZVvhU749dkk+B8IuxGzHOb6wdPkDo=@lists.osuosl.org X-Gm-Message-State: AOJu0YziBr85/Ydg/OeBN7LGpu8ZZ+uTXCkcZi9yv0sABW/HQ4p3QkwQ Atiicnr/tY3993Tq7Ik/mJ2odYZ7n1WMgPt/6kH4EMMss48qF59RPQMSg9q/JnI= X-Google-Smtp-Source: AGHT+IHXXArha9jNHjLZbUZOKXb2fAUQmfhtIzPjAskZgyUcPyxmLBYIsFCiKKKWKAuVsa/v95cbrA== X-Received: by 2002:a05:6a21:3942:b0:1d9:17fa:e5d8 with SMTP id adf61e73a8af0-1d978b3e396mr3930524637.26.1729704484409; Wed, 23 Oct 2024 10:28:04 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec13355casm6554748b3a.59.2024.10.23.10.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 10:28:04 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: jacob.e.keller@intel.com, Joe Damato , Dmitry Antipov , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Date: Wed, 23 Oct 2024 17:27:45 +0000 Message-Id: <20241023172745.181265-1-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729704484; x=1730309284; darn=lists.osuosl.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XDXXNue6psjylQE85p9KLrQo9I2faybviN6SW/hT9xU=; b=ZD7XlAp+x+E3ngEFcLDX9a1xdQxt4hh2c3J38L4sNVsMBMRV/GQCAlUbsmdXbNcB/D sFpeJ2TF3dr/1JSfcZISugkK3XczCItYD/g7+x0uUMhQE/IMIlvnZfc2EJgasoIeIXWO wmSCsketo8i4K4+2V8NOrDxMgPNz2DP8STnYA= X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=reject dis=none) header.from=fastly.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=fastly.com header.i=@fastly.com header.a=rsa-sha256 header.s=google header.b=ZD7XlAp+ Subject: [Intel-wired-lan] [iwl-net v2] e1000: Hold RTNL when e1000_down can be called X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" e1000_down calls netif_queue_set_napi, which assumes that RTNL is held. There are a few paths for e1000_down to be called in e1000 where RTNL is not currently being held: - e1000_shutdown (pci shutdown) - e1000_suspend (power management) - e1000_reinit_locked (via e1000_reset_task delayed work) - e1000_io_error_detected (via pci error handler) Hold RTNL in three places to fix this issue: - e1000_reset_task: igc, igb, and e100e all hold rtnl in this path. - e1000_io_error_detected (pci error handler): e1000e and ixgbe hold rtnl in this path. A patch has been posted for igc to do the same [1]. - __e1000_shutdown (which is called from both e1000_shutdown and e1000_suspend): igb, ixgbe, and e1000e all hold rtnl in the same path. The other paths which call e1000_down seemingly hold RTNL and are OK: - e1000_close (ndo_stop) - e1000_change_mtu (ndo_change_mtu) Based on the above analysis and mailing list discussion [2], I believe adding rtnl in the three places mentioned above is correct. Fixes: 8f7ff18a5ec7 ("e1000: Link NAPI instances to queues and IRQs") Reported-by: Dmitry Antipov Closes: https://lore.kernel.org/netdev/8cf62307-1965-46a0-a411-ff0080090ff9@yandex.ru/ Link: https://lore.kernel.org/netdev/20241022215246.307821-3-jdamato@fastly.com/ [1] Link: https://lore.kernel.org/netdev/ZxgVRX7Ne-lTjwiJ@LQ3V64L9R2/ [2] Signed-off-by: Joe Damato --- v2: - No longer an RFC - Include an rtnl_lock/rtnl_unlock in e1000_io_error_detected inspired by ixgbe's implementation of the same drivers/net/ethernet/intel/e1000/e1000_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) base-commit: d05596f248578be943015c1237120574a8d845dd diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 4de9b156b2be..3f089c3d47b2 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -3509,7 +3509,9 @@ static void e1000_reset_task(struct work_struct *work) container_of(work, struct e1000_adapter, reset_task); e_err(drv, "Reset adapter\n"); + rtnl_lock(); e1000_reinit_locked(adapter); + rtnl_unlock(); } /** @@ -5074,7 +5076,9 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) usleep_range(10000, 20000); WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); + rtnl_lock(); e1000_down(adapter); + rtnl_unlock(); } status = er32(STATUS); @@ -5235,16 +5239,20 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); + rtnl_lock(); netif_device_detach(netdev); - if (state == pci_channel_io_perm_failure) + if (state == pci_channel_io_perm_failure) { + rtnl_unlock(); return PCI_ERS_RESULT_DISCONNECT; + } if (netif_running(netdev)) e1000_down(adapter); if (!test_and_set_bit(__E1000_DISABLED, &adapter->flags)) pci_disable_device(pdev); + rtnl_unlock(); /* Request a slot reset. */ return PCI_ERS_RESULT_NEED_RESET;