Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1484191 > unrolled thread

[PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock

Started byVaishali Thakkar <vaishali.thakkar@oracle.com>
First post2016-09-15 16:00 +0200
Last post2016-09-15 16:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock Vaishali Thakkar <vaishali.thakkar@oracle.com> - 2016-09-15 16:00 +0200
    Re: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under  spinlock John Garry <john.garry@huawei.com> - 2016-09-15 16:20 +0200
      Re: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under  spinlock John Garry <john.garry@huawei.com> - 2016-09-15 16:20 +0200

#1484191 — [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock

FromVaishali Thakkar <vaishali.thakkar@oracle.com>
Date2016-09-15 16:00 +0200
Subject[PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock
Message-ID<shFmO-7Jn-9@gated-at.bofh.it>
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 <vaishali.thakkar@oracle.com>
---
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);
+
 	/* 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;
-- 
2.1.4

[toc] | [next] | [standalone]


#1484214 — Re: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock

FromJohn Garry <john.garry@huawei.com>
Date2016-09-15 16:20 +0200
SubjectRe: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock
Message-ID<shFG9-85o-3@gated-at.bofh.it>
In reply to#1484191
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 <vaishali.thakkar@oracle.com>
> ---
> 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?

>  	/* 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;
>

[toc] | [prev] | [next] | [standalone]


#1484218 — Re: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock

FromJohn Garry <john.garry@huawei.com>
Date2016-09-15 16:20 +0200
SubjectRe: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock
Message-ID<shFGa-85o-21@gated-at.bofh.it>
In reply to#1484214
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 <vaishali.thakkar@oracle.com>
>> ---
>> 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
>
> .
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web