From patchwork Thu Sep 15 13:48:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 9333709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 366E16077A for ; Thu, 15 Sep 2016 13:51:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20A42297BB for ; Thu, 15 Sep 2016 13:51:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15027297C2; Thu, 15 Sep 2016 13:51:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CF3D297BB for ; Thu, 15 Sep 2016 13:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759453AbcIONvv (ORCPT ); Thu, 15 Sep 2016 09:51:51 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:17084 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757592AbcIONth (ORCPT ); Thu, 15 Sep 2016 09:49:37 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8FDnYTe014342 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 15 Sep 2016 13:49:35 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8FDnYo3004241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 15 Sep 2016 13:49:34 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8FDnNre021375; Thu, 15 Sep 2016 13:49:29 GMT Received: from vaishali.oracle.com (/106.66.110.72) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 15 Sep 2016 06:49:23 -0700 From: Vaishali Thakkar To: jejb@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, Vaishali Thakkar Subject: [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock Date: Thu, 15 Sep 2016 19:18:31 +0530 Message-Id: <1473947311-9573-1-git-send-email-vaishali.thakkar@oracle.com> X-Mailer: git-send-email 2.1.4 X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); + /* 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;