提交 a3c26000 编写于 作者: A Ahmed S. Darwish 提交者: Zheng Zengkai

scsi: hisi_sas: Remove preemptible()

mainline inclusion
from mainline-master
commit 18577cdc
category: bugfix
bugzilla: 175270
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=18577cdcaeeb7a1ca5c3adc4d92ed2ba75699625

------------------------------------------------------------------------

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.

Link: https://lore.kernel.org/r/20201126132952.2287996-3-bigeasy@linutronix.de
Fixes: 214e702d ("scsi: hisi_sas: Adjust task reject period during host reset")
Fixes: 550c0d89 ("scsi: hisi_sas: Replace in_softirq() check in hisi_sas_task_exec()")
Cc: Xiaofei Tan <tanxiaofei@huawei.com>
Cc: Xiang Chen <chenxiang66@hisilicon.com>
Cc: John Garry <john.garry@huawei.com>
Acked-by: NJohn Garry <john.garry@huawei.com>
Signed-off-by: NAhmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: NOuyangdelong <ouyangdelong@huawei.com>
Signed-off-by: NNifujia <nifujia1@hisilicon.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 90d762c4
...@@ -591,13 +591,7 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, ...@@ -591,13 +591,7 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags,
dev = hisi_hba->dev; dev = hisi_hba->dev;
if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) {
/* if (!gfpflags_allow_blocking(gfp_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())
return -EINVAL; return -EINVAL;
down(&hisi_hba->sem); down(&hisi_hba->sem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册