From patchwork Thu Oct 24 14:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177511 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2248920ill; Thu, 24 Oct 2019 07:12:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKGd1Lyl9I7/5LaH3Xi8J/4nbhiU+DbXFPHm78dwmn2BP10X6a5wHCbaLM37F6IutcDf+R X-Received: by 2002:a05:6402:1687:: with SMTP id a7mr43798058edv.222.1571926371931; Thu, 24 Oct 2019 07:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926371; cv=none; d=google.com; s=arc-20160816; b=ByXoEzQmVpNraguHd0IQvu9pbsSwYhus7vY9pv2fSkvilv4rtHH6DGBOyvaYdKb5DZ QaUOpXFanEuQDl8KhPwYhTSb2PVL1wTK27Wc3gg6pcm45SXXQhH9UINw3wFGCijLAIQr lR1JD0ATs+XosjO4JfNiwJA89MgMF4aB/B39U/gtPUa4JoZ4MV5cV8ZUiQLuIEdqazbB o5SooE2QZUsWMgL9St8riKgSGn+bbed+XqHdD5FL+93WLeGQ7DxX9FatfgpBmFxHoLff zesagzNnuVpbmtU2X5LEsq9SSz4+uvZtqcBzLkFfWWcqWohw3NYHdjHgaAIDZ5/bJaI+ aoZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=gS6flLkx0i7o+2b+qVhUf8ULAteyuD3kDv1Z5xJs8co=; b=oc26BdMXJpeoNz1UhEyZS8g/5wV6vqTdX5bO1LiWgnEqseqp0gauk3b6XMq42nYUO7 CWCMxZ4C6WMjwcTjOV/OMgU5MotxugzQh4sOGyghKc0Pm9M8WjUoMmeeYCDB6NdltNGK uOfBLMsFt/u9B+7TSsAeZk0LoXfaMhbFJhwbj/H6J6Q1oX535kRSuUcCxjeTdgC9JlTz S5CUuu1SgVd4T7mYpui2fl4FW4BebQywJjcqnsNtgK3a5w5HzgBuZJ/iEiLswp/3K4KX r6WqIJRTCWrckx8F/70O8g6TWSKQvLUij2VjCRekjoSmncndiJEbhDYOfgb+47WUrbrS nxYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 b53si10588448edb.419.2019.10.24.07.12.51 for ; Thu, 24 Oct 2019 07:12:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393869AbfJXOMs (ORCPT ); Thu, 24 Oct 2019 10:12:48 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5172 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502600AbfJXOLr (ORCPT ); Thu, 24 Oct 2019 10:11:47 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C53F43DA15A3B5448E3F; Thu, 24 Oct 2019 22:11:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:11:24 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH v2 04/18] scsi: hisi_sas: Replace in_softirq() check in hisi_sas_task_exec() Date: Thu, 24 Oct 2019 22:08:11 +0800 Message-ID: <1571926105-74636-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926105-74636-1-git-send-email-john.garry@huawei.com> References: <1571926105-74636-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiang Chen 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. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 621eebbeacd6..a7bac5dc389a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -587,7 +587,13 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, dev = hisi_hba->dev; 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);