Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3388256rwa; Tue, 23 Aug 2022 04:05:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wRmzKgIVu8Kih9odziVR5SYtppk8N1m6ZGwWbXWNcTMVS2SNbGXoSZBNkJ1zquqqs2cYV X-Received: by 2002:a05:6a00:2349:b0:536:bf09:9c0a with SMTP id j9-20020a056a00234900b00536bf099c0amr7042680pfj.32.1661252721567; Tue, 23 Aug 2022 04:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661252721; cv=none; d=google.com; s=arc-20160816; b=bJsfirSid8JkaHULYbJPRUv9m7cKCk2wcT+QxUTUCbsUwzkwznhRPuYlt60ovFDS9m 45xajfSMT3Ipw20bo8R2F7NNtkLVktSjYdM2eSgxUuOUR+kA4//8sTB9JKEB60FVfmDW SR0IwRqD9ttPUwlcZu/gjBaDT6bOdhXua89aLexHk0/oBf7ofzQ4Jg8rjFzBXp15Xr91 MluVEmUGhfQfOhj0J5N/0ejWD4g4dvJwh3EKyIqX1y2CqE4BUS9VKSK6Ziv5w0ZcnQjG F1RiqnwEjfgnxfcsz/75a6tHyVCc/dOGxPgaEhVkmMb0FUt5ZvYyy9ECH2cGGEpICUq7 r5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3c02y5cckJrO1vDKwifqkYbrgtFq92olBIesRF+E0h4=; b=nLPPVwOvTNcJf3ks/9/jkURO7djiNt0jrPZcoIbrKCWiCCBoEz2Qcn1yMm9i0rC5lZ WcHIFucD9mMGXtJ0pXQjpvoVHFDfnmPgwbUSA2Y/yFyhdHWHv7y36K8ck18Gw8f8b6Ge wyn2ZcXs5fLuPmjQiWcdNsbg2OcR8qbqepuZ/cDeWPWS2GDFy0k91lQLosE8X75ZGFuJ Gu3acjISIrNoQBvI3+R5LZlLHA7fomoWOgBqL34W6atRM1kVAyU/aDRSmc3ODlNfRbSC uFmsoAszLWIGRUc795r0dW70YvPDil1O8MsJfQyITd7oDPPLhbfcHFTiESlNjUG2gT5F UWVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="tZQ/5Ii0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a170902e94800b00172b5eddefcsi14448060pll.180.2022.08.23.04.05.07; Tue, 23 Aug 2022 04:05:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="tZQ/5Ii0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351177AbiHWJgu (ORCPT + 99 others); Tue, 23 Aug 2022 05:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351335AbiHWJf2 (ORCPT ); Tue, 23 Aug 2022 05:35:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9214396FD3; Tue, 23 Aug 2022 01:39:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3B16DB81C4A; Tue, 23 Aug 2022 08:18:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C612C433C1; Tue, 23 Aug 2022 08:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242703; bh=F5vRVgkLbGhcuVsIbIHpjZEGgUqsHRcnYDVsI2aUkUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZQ/5Ii0FmXIEJizZO4nlwuzh8ioD6ekmYI5Yy6mfGfdW5HOSFQM0tktgvgfezXt8 +vHa96L1jRLNq5PGR1s7feiqIRtBD/kPrvGpMjMm4bh2xibMqy0tOJSGR1WfJb2auZ nDrhfVovMiC4sASDwoKK90ESorpf5swfC+Ds6Vus= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Przemyslaw Patynowski , Jedrzej Jagielski , Marek Szlosek , Tony Nguyen Subject: [PATCH 5.19 174/365] iavf: Fix reset error handling Date: Tue, 23 Aug 2022 10:01:15 +0200 Message-Id: <20220823080125.488748567@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Przemyslaw Patynowski commit 31071173771e079f7bc08dacd61e0db913262fbf upstream. Do not call iavf_close in iavf_reset_task error handling. Doing so can lead to double call of napi_disable, which can lead to deadlock there. Removing VF would lead to iavf_remove task being stuck, because it requires crit_lock, which is held by iavf_close. Call iavf_disable_vf if reset fail, so that driver will clean up remaining invalid resources. During rapid VF resets, HW can fail to setup VF mailbox. Wrong error handling can lead to iavf_remove being stuck with: [ 5218.999087] iavf 0000:82:01.0: Failed to init adminq: -53 ... [ 5267.189211] INFO: task repro.sh:11219 blocked for more than 30 seconds. [ 5267.189520] Tainted: G S E 5.18.0-04958-ga54ce3703613-dirty #1 [ 5267.189764] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 5267.190062] task:repro.sh state:D stack: 0 pid:11219 ppid: 8162 flags:0x00000000 [ 5267.190347] Call Trace: [ 5267.190647] [ 5267.190927] __schedule+0x460/0x9f0 [ 5267.191264] schedule+0x44/0xb0 [ 5267.191563] schedule_preempt_disabled+0x14/0x20 [ 5267.191890] __mutex_lock.isra.12+0x6e3/0xac0 [ 5267.192237] ? iavf_remove+0xf9/0x6c0 [iavf] [ 5267.192565] iavf_remove+0x12a/0x6c0 [iavf] [ 5267.192911] ? _raw_spin_unlock_irqrestore+0x1e/0x40 [ 5267.193285] pci_device_remove+0x36/0xb0 [ 5267.193619] device_release_driver_internal+0xc1/0x150 [ 5267.193974] pci_stop_bus_device+0x69/0x90 [ 5267.194361] pci_stop_and_remove_bus_device+0xe/0x20 [ 5267.194735] pci_iov_remove_virtfn+0xba/0x120 [ 5267.195130] sriov_disable+0x2f/0xe0 [ 5267.195506] ice_free_vfs+0x7d/0x2f0 [ice] [ 5267.196056] ? pci_get_device+0x4f/0x70 [ 5267.196496] ice_sriov_configure+0x78/0x1a0 [ice] [ 5267.196995] sriov_numvfs_store+0xfe/0x140 [ 5267.197466] kernfs_fop_write_iter+0x12e/0x1c0 [ 5267.197918] new_sync_write+0x10c/0x190 [ 5267.198404] vfs_write+0x24e/0x2d0 [ 5267.198886] ksys_write+0x5c/0xd0 [ 5267.199367] do_syscall_64+0x3a/0x80 [ 5267.199827] entry_SYSCALL_64_after_hwframe+0x46/0xb0 [ 5267.200317] RIP: 0033:0x7f5b381205c8 [ 5267.200814] RSP: 002b:00007fff8c7e8c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 5267.201981] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f5b381205c8 [ 5267.202620] RDX: 0000000000000002 RSI: 00005569420ee900 RDI: 0000000000000001 [ 5267.203426] RBP: 00005569420ee900 R08: 000000000000000a R09: 00007f5b38180820 [ 5267.204327] R10: 000000000000000a R11: 0000000000000246 R12: 00007f5b383c06e0 [ 5267.205193] R13: 0000000000000002 R14: 00007f5b383bb880 R15: 0000000000000002 [ 5267.206041] [ 5267.206970] Kernel panic - not syncing: hung_task: blocked tasks [ 5267.207809] CPU: 48 PID: 551 Comm: khungtaskd Kdump: loaded Tainted: G S E 5.18.0-04958-ga54ce3703613-dirty #1 [ 5267.208726] Hardware name: Dell Inc. PowerEdge R730/0WCJNT, BIOS 2.11.0 11/02/2019 [ 5267.209623] Call Trace: [ 5267.210569] [ 5267.211480] dump_stack_lvl+0x33/0x42 [ 5267.212472] panic+0x107/0x294 [ 5267.213467] watchdog.cold.8+0xc/0xbb [ 5267.214413] ? proc_dohung_task_timeout_secs+0x30/0x30 [ 5267.215511] kthread+0xf4/0x120 [ 5267.216459] ? kthread_complete_and_exit+0x20/0x20 [ 5267.217505] ret_from_fork+0x22/0x30 [ 5267.218459] Fixes: f0db78928783 ("i40evf: use netdev variable in reset task") Signed-off-by: Przemyslaw Patynowski Signed-off-by: Jedrzej Jagielski Tested-by: Marek Szlosek Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -2998,12 +2998,15 @@ continue_reset: return; reset_err: + if (running) { + set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); + iavf_free_traffic_irqs(adapter); + } + iavf_disable_vf(adapter); + mutex_unlock(&adapter->client_lock); mutex_unlock(&adapter->crit_lock); - if (running) - iavf_change_state(adapter, __IAVF_RUNNING); dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); - iavf_close(netdev); } /**