From patchwork Thu Nov 26 13:29:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 333388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ECE7C56202 for ; Thu, 26 Nov 2020 13:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42E1121D7E for ; Thu, 26 Nov 2020 13:30:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ymCbyc72"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="56vEOwTk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390057AbgKZNad (ORCPT ); Thu, 26 Nov 2020 08:30:33 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:56450 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389955AbgKZNad (ORCPT ); Thu, 26 Nov 2020 08:30:33 -0500 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1606397430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nCHH+WU06bIildt8jR1f7yAZJ5+Z7ksfyeAxtSEkZIU=; b=ymCbyc72lNOJoMf8MAh/+bYJSFOWyhWk4LQDgL0Bf4p0cxZgu/X9P//oLgEvmaE9j1NlAO iDejMtK/wOQNxEEdQVcEDjwg9Opugw3bs4Rrne8gmv10tN0DpyeWSwWVdq4op2K2fcNVka QsW1YvX5dO6+SohMqlr6BjtyM6r5yPuk7BlHKXcsJSCs2cntkBf2H2/ItzqpUU/EErnkhg PdhL5Lvy4HR6OL2FwXyJI7HLIBzpJryCLuEsT5QDYuhftPDnF/X2xAtQllWAAjhHKbIyPq xPmCUu1nEb6wEaSkQHedS9O3lCBhOnc24+BTWipWFrBghUAAi8CuD5IoOT1hUg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1606397430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nCHH+WU06bIildt8jR1f7yAZJ5+Z7ksfyeAxtSEkZIU=; b=56vEOwTkXDyd7Tk8GeC8Gtc6EyM5DiXVrmPEXaoyCiQugDjuuWpIl8J7nmvRle7ku7VUGm VkfdlHk6tRQVJCAg== To: linux-scsi@vger.kernel.org Cc: Finn Thain , GR-QLogic-Storage-Upstream@marvell.com, Hannes Reinecke , Jack Wang , John Garry , linux-m68k@lists.linux-m68k.org, Manish Rangankar , Michael Schmitz , MPT-FusionLinux.pdl@broadcom.com, Nilesh Javali , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Vikram Auradkar , Xiang Chen , Xiaofei Tan , "James E . J . Bottomley" , "Martin K . Petersen" , Thomas Gleixner , "Ahmed S . Darwish" , Sebastian Andrzej Siewior Subject: [PATCH 02/14] scsi: hisi_sas: Remove preemptible(). Date: Thu, 26 Nov 2020 14:29:40 +0100 Message-Id: <20201126132952.2287996-3-bigeasy@linutronix.de> In-Reply-To: <20201126132952.2287996-1-bigeasy@linutronix.de> References: <20201126132952.2287996-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: "Ahmed S. Darwish" hisi_sas_task_exec() uses preemptible() to see if it's safe to block. This does not work for CONFIG_PREEMPT_COUNT=n kernels in which preemptible() always returns 0. The problem is masked when enabling some of the common Kconfig.debug options (like CONFIG_DEBUG_ATOMIC_SLEEP), as they implicitly enable the preemption counter. In general, driver leaf functions should not make logic decisions based on the context they're called from. The caller should be the entity responsible for explicitly indicating context. Since hisi_sas_task_exec() already has a gfp_t flags parameter, use it as the explicit context marker. Fixes: 214e702d4b70 ("scsi: hisi_sas: Adjust task reject period during host reset") Fixes: 550c0d89d52d ("scsi: hisi_sas: Replace in_softirq() check in hisi_sas_task_exec()") Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior Cc: Xiaofei Tan Cc: Xiang Chen Cc: John Garry Acked-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index c8dd8588f800e..06e65c461f027 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -585,13 +585,7 @@ 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))) { - /* - * 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()) + if (!gfpflags_allow_blocking(gfp_flags)) return -EINVAL; down(&hisi_hba->sem);