From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934540AbcIOOPA (ORCPT ); Thu, 15 Sep 2016 10:15:00 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:61718 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934242AbcIOOOu (ORCPT ); Thu, 15 Sep 2016 10:14:50 -0400 Subject: Re: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock To: Vaishali Thakkar , References: <1473947311-9573-1-git-send-email-vaishali.thakkar@oracle.com> CC: , , From: John Garry Message-ID: <5c68b70f-e20e-08e4-66f9-2090806b0078@huawei.com> Date: Thu, 15 Sep 2016 15:14:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.181.151] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.57DAACCA.014C,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9f87b31d75d660cfe2d4f63a80c9a3a1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/09/2016 15:08, John Garry wrote: > On 15/09/2016 14:48, Vaishali Thakkar wrote: >> It is preferrable to use request_firmware where sleeping is >> allowed. Using it under spinlock can cause blocking. Here, >> the function wd719x_chip_init calls request_firmware while >> holding a spinlock. So, let's access it outside the spinlock. >> >> Coccinelle is used to detect the issue. >> >> Signed-off-by: Vaishali Thakkar >> --- >> Please note that the patch is compile-tested only. And this change >> may require driver testing. >> --- >> drivers/scsi/wd719x.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c >> index e3da1a2..b8e57f3 100644 >> --- a/drivers/scsi/wd719x.c >> +++ b/drivers/scsi/wd719x.c >> @@ -518,13 +518,14 @@ static int wd719x_host_reset(struct scsi_cmnd *cmd) >> int result; >> >> dev_info(&wd->pdev->dev, "host reset requested\n"); >> - spin_lock_irqsave(wd->sh->host_lock, flags); >> + > > In the version of code I have flags is only used for this spinlock, so > can flags be removed? I see we're just relocating the spinlock, so ignore me > >> /* Try to reinit the RISC */ >> if (wd719x_chip_init(wd) == 0) >> result = SUCCESS; >> else >> result = FAILED; >> >> + spin_lock_irqsave(wd->sh->host_lock, flags); >> /* flush all SCBs */ >> list_for_each_entry_safe(scb, tmp, &wd->active_scbs, list) { >> struct scsi_cmnd *tmp_cmd = scb->cmd; >> > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > . >