Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17925884ybl; Thu, 2 Jan 2020 14:57:35 -0800 (PST) X-Google-Smtp-Source: APXvYqw69+7ltED4z6o67bRryKZJ+hVF0JU714S9jwFNy3wrtjTNZSF2GV3yg0M9dP7J/RMfgmyo X-Received: by 2002:a05:6830:1707:: with SMTP id 7mr69039681otk.235.1578005855596; Thu, 02 Jan 2020 14:57:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005855; cv=none; d=google.com; s=arc-20160816; b=N5fchCWyVsYKO4/0st7msFHRvHarlXN/znMtPrt8j2Jpi9w+GqUBwc3OKwewvK1z7R e3cgK8FyMQjKnnJSdCiUmiAwpz8rcZ95KaAgdGfDr0ZwHMKyjj4O/pY240xVaE+mz43N VdWxt7EjjTYtTwXKuzxxUqLCyNjUYAhKG8Ao8kBkVowtj1HF3wLTt1n0K7RSVH8L/dkN lcVHH1ngyeDdOAJHxwxCKlc5Qa9YTczXfBzb17es5EZMHfCZhGr4q8wfc/s3VE+7ydMH tlDJvXqOnkR4rnoc+xWdX17AZChCnfmOkrGPiwnSqUkRPdOOULkIBhWcylk96W+pD7Wg bZyA== 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=mHyi2hh3g4sKlMQbE/kMuS+nOjAlVN5Xf4aCBJKpqSU=; b=uf9Aq3ePpBYXaChYocVXCDoCafzif6RrIf8HKh4ZXh8W5wo+sdTcEh0HylYXjVyICe lCAeh3vvwxRjOD672hjMpTlVnR2vSZ0XS5SGNjnGm5LCNzSk8nGdNwon0YaYxhL5OldR i0sUUqyr5mMDQ1ddzBueTufLUgrVXOJfvvQFB4HEzh5WF+VcJoSFnUZt/GUrhShMHiem uLWbbvkaqSevqKz/6VyK4XIxldn6LwJ7cXw+U9LWeC6a/MJbaSoVckaLBKdgBV0BCMYG Kyt7gqMAGAvY1/iWZ59q4LGjbXhrUcdT28gHYvngHc5oFC84Tkz9+xMvCVOnoOoHe8rK KmUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YrHNAEGl; 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 v6si29094699ota.19.2020.01.02.14.57.24; Thu, 02 Jan 2020 14:57:35 -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=YrHNAEGl; 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 S1728523AbgABWTD (ORCPT + 99 others); Thu, 2 Jan 2020 17:19:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:34796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728497AbgABWTC (ORCPT ); Thu, 2 Jan 2020 17:19:02 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 98F2821582; Thu, 2 Jan 2020 22:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003541; bh=6v7SqYOffrsxvnPYUOOCvnJoyLw2eZJ622LJOKWVnSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YrHNAEGljCxW9U5vAzVG7ppx6aaWsJzzgN4/oyqm8dhT5VdrUTDIVFzNC/zTGct1x GPMWXnDI4fmsXalIVGDxPX4Oky7SaV9Hsm/EKeDSWQrTxEQVS9epSdzgZoh+cCqPeF vnf7zfIjx4TwQ14P6DraacfvGHSJ90FWGwlxfz7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 012/114] scsi: hisi_sas: Replace in_softirq() check in hisi_sas_task_exec() Date: Thu, 2 Jan 2020 23:06:24 +0100 Message-Id: <20200102220030.364541809@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Xiang Chen [ Upstream commit 550c0d89d52d3bec5c299f69b4ed5d2ee6b8a9a6 ] For IOs from upper layer, preemption may be disabled as it may be called by function __blk_mq_delay_run_hw_queue which will call get_cpu() (it disables preemption). So if flags HISI_SAS_REJECT_CMD_BIT is set in function hisi_sas_task_exec(), it may disable preempt twice after down() and up() which will cause following call trace: BUG: scheduling while atomic: fio/60373/0x00000002 Call trace: dump_backtrace+0x0/0x150 show_stack+0x24/0x30 dump_stack+0xa0/0xc4 __schedule_bug+0x68/0x88 __schedule+0x4b8/0x548 schedule+0x40/0xd0 schedule_timeout+0x200/0x378 __down+0x78/0xc8 down+0x54/0x70 hisi_sas_task_exec.isra.10+0x598/0x8d8 [hisi_sas_main] hisi_sas_queue_command+0x28/0x38 [hisi_sas_main] sas_queuecommand+0x168/0x1b0 [libsas] scsi_queue_rq+0x2ac/0x980 blk_mq_dispatch_rq_list+0xb0/0x550 blk_mq_do_dispatch_sched+0x6c/0x110 blk_mq_sched_dispatch_requests+0x114/0x1d8 __blk_mq_run_hw_queue+0xb8/0x130 __blk_mq_delay_run_hw_queue+0x1c0/0x220 blk_mq_run_hw_queue+0xb0/0x128 blk_mq_sched_insert_requests+0xdc/0x208 blk_mq_flush_plug_list+0x1b4/0x3a0 blk_flush_plug_list+0xdc/0x110 blk_finish_plug+0x3c/0x50 blkdev_direct_IO+0x404/0x550 generic_file_read_iter+0x9c/0x848 blkdev_read_iter+0x50/0x78 aio_read+0xc8/0x170 io_submit_one+0x1fc/0x8d8 __arm64_sys_io_submit+0xdc/0x280 el0_svc_common.constprop.0+0xe0/0x1e0 el0_svc_handler+0x34/0x90 el0_svc+0x10/0x14 ... To solve the issue, check preemptible() to avoid disabling preempt multiple when flag HISI_SAS_REJECT_CMD_BIT is set. Link: https://lore.kernel.org/r/1571926105-74636-5-git-send-email-john.garry@huawei.com Signed-off-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index f35c56217694..33191673249c 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -485,7 +485,13 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, struct hisi_sas_dq *dq = NULL; if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { - if (in_softirq()) + /* + * For IOs from upper layer, it may already disable preempt + * in the IO path, if disable preempt again in down(), + * function schedule() will report schedule_bug(), so check + * preemptible() before goto down(). + */ + if (!preemptible()) return -EINVAL; down(&hisi_hba->sem); -- 2.20.1