Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2691692imj; Mon, 11 Feb 2019 07:05:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IaYpwBgd+XRUiAWuDmPxhJ0qruF5o+Cl9NeO3cT8SK/OnVBMwYdGZNCbcmoYFEgbco1fGfj X-Received: by 2002:a63:7f46:: with SMTP id p6mr33894500pgn.54.1549897548193; Mon, 11 Feb 2019 07:05:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897548; cv=none; d=google.com; s=arc-20160816; b=f5MhZT3ig/W1oR9lXckYcyFAIUcagvDD24tE2aBnHMkb31wAkvuNrP0dbd9dqJ8rcs +9SlB3Vhlx52STookZ871gXEG+Y/yy6/7Twwkkpum8qyTOBxSNXuEa72wrxiqB3mEJat rRxwVSKyab5NWGVZkSOcYFU6mPr/vqPEXeHlB2xThjAzGlosPkwE1kR4R/RDZCjbDw7u ntVe6k9coLwClLXyGC4QDiC/p1OnFhhgYxYUbz6pdf8BbG+S9q9k6JhnRUvul/fiTAqJ 1VL6NAzDd7VOJcXdol2OY9poGLTgMMez/5T3OzkUY2MoEB3NY4sVwmuBM7mm4IwDu2Co zlyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2Kfqx2jYcNgjDOwYh8LX/r4rVJ6S2TXszio3BVCVGeM=; b=xu3jlAhjJwzm7nJVEm0WIya/IKSEonKfnQFgUgrnZXRFXZfEgsLbfQUkYF7MwuChWU FF9+5VA3k1JRmUFR6i9Vgsn4NyOnNI1yPnlX5N2/r+P6QZoByB4IRiCUFE6xcpVYPzKo i3pWVUWrzydyOTDdxPY7jFfueM/Vrs5Vw2/DpjIxdvQuBlKF1c0Lgq1/dUQT9305xzzg Cg548OoTZh4+Sib3+qcXPAG33L/qMY5c/HPufiQycYtrIrFh/G2nwtlJLo0PhluY4i5t CQQkE0tgJ0qiSmvJItWKxH5WGWrTXr50ThEZ344ODE1fjH2mLQ/0cf4VfxEq9TkMOpl+ TUzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IhprpRcz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 206si9621065pga.240.2019.02.11.07.05.29; Mon, 11 Feb 2019 07:05:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IhprpRcz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390777AbfBKPE0 (ORCPT + 99 others); Mon, 11 Feb 2019 10:04:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:53378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390760AbfBKPEW (ORCPT ); Mon, 11 Feb 2019 10:04:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E6D1222B0; Mon, 11 Feb 2019 15:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897462; bh=oM1ycKiAYlMVQTyFT8HD1tuwk+dtPPXaouvmVQaPiGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IhprpRczVK3UX5RkphBKyxox4PjsTXb4L3MDRmBnGAZhCBGO3Z/i7jDR9Sh59BUgZ zM+8VTKCw7ebIRbLWaFcv8o7aLnPHeiJyTLnGnQ52jk41PE9PXXi3AbWDEoVYWsC7T cRSkNi559MHJ3caYX4DzkhNqWuPHrNCE0J6Hj8YI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vaibhav Jain , "Martin K. Petersen" Subject: [PATCH 4.14 190/205] scsi: cxlflash: Prevent deadlock when adapter probe fails Date: Mon, 11 Feb 2019 15:19:48 +0100 Message-Id: <20190211141840.848393594@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vaibhav Jain commit bb61b843ffd46978d7ca5095453e572714934eeb upstream. Presently when an error is encountered during probe of the cxlflash adapter, a deadlock is seen with cpu thread stuck inside cxlflash_remove(). Below is the trace of the deadlock as logged by khungtaskd: cxlflash 0006:00:00.0: cxlflash_probe: init_afu failed rc=-16 INFO: task kworker/80:1:890 blocked for more than 120 seconds. Not tainted 5.0.0-rc4-capi2-kexec+ #2 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/80:1 D 0 890 2 0x00000808 Workqueue: events work_for_cpu_fn Call Trace: 0x4d72136320 (unreliable) __switch_to+0x2cc/0x460 __schedule+0x2bc/0xac0 schedule+0x40/0xb0 cxlflash_remove+0xec/0x640 [cxlflash] cxlflash_probe+0x370/0x8f0 [cxlflash] local_pci_probe+0x6c/0x140 work_for_cpu_fn+0x38/0x60 process_one_work+0x260/0x530 worker_thread+0x280/0x5d0 kthread+0x1a8/0x1b0 ret_from_kernel_thread+0x5c/0x80 INFO: task systemd-udevd:5160 blocked for more than 120 seconds. The deadlock occurs as cxlflash_remove() is called from cxlflash_probe() without setting 'cxlflash_cfg->state' to STATE_PROBED and the probe thread starts to wait on 'cxlflash_cfg->reset_waitq'. Since the device was never successfully probed the 'cxlflash_cfg->state' never changes from STATE_PROBING hence the deadlock occurs. We fix this deadlock by setting the variable 'cxlflash_cfg->state' to STATE_PROBED in case an error occurs during cxlflash_probe() and just before calling cxlflash_remove(). Cc: stable@vger.kernel.org Fixes: c21e0bbfc485("cxlflash: Base support for IBM CXL Flash Adapter") Signed-off-by: Vaibhav Jain Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/cxlflash/main.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -3659,6 +3659,7 @@ static int cxlflash_probe(struct pci_dev host->max_cmd_len = CXLFLASH_MAX_CDB_LEN; cfg = shost_priv(host); + cfg->state = STATE_PROBING; cfg->host = host; rc = alloc_mem(cfg); if (rc) { @@ -3741,6 +3742,7 @@ out: return rc; out_remove: + cfg->state = STATE_PROBED; cxlflash_remove(pdev); goto out; }