Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3677123pxv; Mon, 26 Jul 2021 09:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjRbWJhjQwPwHtgsHj0+Qms0QY5ZOWrlTJ2Ej8VRWjhYP8g3AajBKBbPQZ+k7rYKvQ+ITB X-Received: by 2002:a05:6402:2206:: with SMTP id cq6mr22475369edb.209.1627315955530; Mon, 26 Jul 2021 09:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315955; cv=none; d=google.com; s=arc-20160816; b=fAJ3oYfv3EZ+pML9w2hUQGVmIhRwAnXNauqZO6oDGj5zL1nJzUxHf9tHbgKa8Ptyeg NDKIcinyN7n/T7jKePKlCo6ZifZwmSu1xiKocwnu8En0WFX0wtKVN2xZQmUl6ZD3zOk4 DMhamPgG1xmi9Gr2NRjAwJBfiTKwsvJBJjz5NjBjbpWctusTbTi+LPRAxPrWi+sx04iI j1FWHCUmn3JQuGAeYX/bmslC0Lih/oLAxCz0senJeCCuuX0FC/Zf6aks8MHGw1mGL31u YdoPRn60Ra72XuW5hvXhFhKNb3cOqNIAZYiPvNfl9zkdkJH5sdb2zWzbxtm7wSqnM9xA Bo4Q== 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=IT5Wja7Se1LXhnF43siX9bDVEDdPAdfhg9d27pZzBU0=; b=wHFsHF9XEFMPTn+hBiagrU2JofRq9oYrsaA6BoxhJcQ3cxhzf72iN1DMmw+uDz3h5X XU9ka8y9OoOYQOelUvpboFOZYciASobxzMX98ppX09MtNw8UnHjqy/yaJlxoAACP6x6q LpgmPZrnyoKfJaYdxGEUrEb6KU2WNhh9LU3bYAzCaIIYLX7Tb1lP3aZhJ7LvDx110JmK UZ6Gzk/HW5odlUqTL8rQBBRFWnwLYhj8F4bC2KaHEnMTIEESQlrfYn2ZvBPmxI+FSRQX 3E6Oz81BKqu/jmJz+l2BvjmHL46oB9dGLZVwrCkscBBzHX6YRupyh41ssOngM61JdE1Z w1+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UXkMbF2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id da17si339072edb.259.2021.07.26.09.12.12; Mon, 26 Jul 2021 09:12:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UXkMbF2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232250AbhGZPaQ (ORCPT + 99 others); Mon, 26 Jul 2021 11:30:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:57158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236513AbhGZPRK (ORCPT ); Mon, 26 Jul 2021 11:17:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E000760F70; Mon, 26 Jul 2021 15:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315055; bh=nOCnzzOAdsN24bfZsElojP6Q2fJlpF1q7LJRy2tPqRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UXkMbF2ggDVFoP4Gj9OCBxtsh6pJ3H0niEdmNLDmrAdMaI9rlD2ybAPuuCgGq9G0d hIZqrgeK9EjWcENPyOGFOu1GzAYOiM9V0BOs1Sn0HfiBHzvu5mrnE62OMvt+NsnYk9 vhNua8+o02EIwxmJPZ1mKn2fHjJgFi/UaVg50nVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhihao Cheng , Sasha Levin Subject: [PATCH 5.4 060/108] nvme-pci: dont WARN_ON in nvme_reset_work if ctrl.state is not RESETTING Date: Mon, 26 Jul 2021 17:39:01 +0200 Message-Id: <20210726153833.616622957@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhihao Cheng [ Upstream commit 7764656b108cd308c39e9a8554353b8f9ca232a3 ] Followling process: nvme_probe nvme_reset_ctrl nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING) queue_work(nvme_reset_wq, &ctrl->reset_work) --------------> nvme_remove nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING) worker_thread process_one_work nvme_reset_work WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING) , which will trigger WARN_ON in nvme_reset_work(): [ 127.534298] WARNING: CPU: 0 PID: 139 at drivers/nvme/host/pci.c:2594 [ 127.536161] CPU: 0 PID: 139 Comm: kworker/u8:7 Not tainted 5.13.0 [ 127.552518] Call Trace: [ 127.552840] ? kvm_sched_clock_read+0x25/0x40 [ 127.553936] ? native_send_call_func_single_ipi+0x1c/0x30 [ 127.555117] ? send_call_function_single_ipi+0x9b/0x130 [ 127.556263] ? __smp_call_single_queue+0x48/0x60 [ 127.557278] ? ttwu_queue_wakelist+0xfa/0x1c0 [ 127.558231] ? try_to_wake_up+0x265/0x9d0 [ 127.559120] ? ext4_end_io_rsv_work+0x160/0x290 [ 127.560118] process_one_work+0x28c/0x640 [ 127.561002] worker_thread+0x39a/0x700 [ 127.561833] ? rescuer_thread+0x580/0x580 [ 127.562714] kthread+0x18c/0x1e0 [ 127.563444] ? set_kthread_struct+0x70/0x70 [ 127.564347] ret_from_fork+0x1f/0x30 The preceding problem can be easily reproduced by executing following script (based on blktests suite): test() { pdev="$(_get_pci_dev_from_blkdev)" sysfs="/sys/bus/pci/devices/${pdev}" for ((i = 0; i < 10; i++)); do echo 1 > "$sysfs/remove" echo 1 > /sys/bus/pci/rescan done } Since the device ctrl could be updated as an non-RESETTING state by repeating probe/remove in userspace (which is a normal situation), we can replace stack dumping WARN_ON with a warnning message. Fixes: 82b057caefaff ("nvme-pci: fix multiple ctrl removal schedulin") Signed-off-by: Zhihao Cheng Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index f9dba1a3e655..af516c35afe6 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2590,7 +2590,9 @@ static void nvme_reset_work(struct work_struct *work) bool was_suspend = !!(dev->ctrl.ctrl_config & NVME_CC_SHN_NORMAL); int result; - if (WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING)) { + if (dev->ctrl.state != NVME_CTRL_RESETTING) { + dev_warn(dev->ctrl.device, "ctrl state %d is not RESETTING\n", + dev->ctrl.state); result = -ENODEV; goto out; } -- 2.30.2