Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9052132imu; Tue, 4 Dec 2018 20:24:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/Whm6RNYBvxuCnL2/8xLgxW9VN/zZO8ZdvByIpjb6rTgKV6lQ7kBKT+LTVyk0xINCIL86Br X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr23195338plp.34.1543983869149; Tue, 04 Dec 2018 20:24:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543983869; cv=none; d=google.com; s=arc-20160816; b=EWIFBJ3uR16LSGzRs4LAcUyejQ7CtMakguKfWTCRY4wTFyAEW+L9/AjgK2sRd6EYoL m4yYryL3QeIfKTWhGWluLZRy4d6W4c+zdrp+F58KTkgVbvl/0xVpfsZKm0E3gEvOOe7U fKSKBpSyFZdQKHQ/rv+P+1kUsjNRQvRfmXHs+U5073gFd6527/LaWSA7Oo6Sfx5X4AgN Rak80xXvCEPrXYL6u4QHkRc1+HveS6vCjPllUj8LbnuOhoSWA9LU9RUhzhKRB4V677DC Va3JUYcwb4SonR5gz+is3MJC0uYxtMRdNDUVxl+kk4a8SkIrrSd6GO4FMAYQvZTJCD5P gMiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QpKMefpqeFlfNQSu4LDGgNW6qVbYiK/EdNzM1deO7AU=; b=JK2HmMqKMWL3BL9LF+K+oUd+7sJbuYQIf/UVqGwMYL4V+7ylc/ZHymH+9dpl/2sCs8 GWm8KSNaoCLXhWfLiPT4lBKbGBEJCGj9oLLL/FTkSLvnS+zcPxWDkCBXRfRnkA4fA9jK xfaRp2xuuCpH+BX+LFglG6nTVWyxb6RMN933KnMJHT6pk8o2TzWgQ5oTywosO/AuKPZG 7MncZF61XLAr29/Ul0iKO9FjnWu9IuoxRXlz0aBUdoHqcu+4Lc8vX7YDUnZdYCc9Nmah cZytK4d+G+a+1ohIYVko/rWIGV0dqIbWEcleLcs5eRETJmmPpvNb5X/Y4b/Bn43PbREF meWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d36si19959296pla.216.2018.12.04.20.24.13; Tue, 04 Dec 2018 20:24:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbeLEEWL (ORCPT + 99 others); Tue, 4 Dec 2018 23:22:11 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:49264 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeLEEWL (ORCPT ); Tue, 4 Dec 2018 23:22:11 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id A741AF0C777293CC9510; Wed, 5 Dec 2018 12:22:07 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB54M1PE014851; Wed, 5 Dec 2018 12:22:01 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from LIN-A6CB96A0603.zte.intra ([10.90.106.118]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018120512222245-14831665 ; Wed, 5 Dec 2018 12:22:22 +0800 From: Wen Yang To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang Subject: [PATCH] scsi: wd719x: Fix sleeping under a spinlock Date: Wed, 5 Dec 2018 12:21:44 +0800 Message-Id: <20181205042144.14174-1-wen.yang99@zte.com.cn> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-12-05 12:22:22, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-05 12:21:54 Content-Transfer-Encoding: quoted-printable X-MAIL: mse01.zte.com.cn wB54M1PE014851 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, dma=5Falloc=5Fcoherent is being called with a GFP=5FKERNEL flag which allows it to sleep with a spinlock held. The call tree is: wd719x=5Fhost=5Freset() holds wd->sh->host=5Flock -> wd719x=5Fchip=5Finit() -> dma=5Falloc=5Fcoherent() uses GFP=5FKERNEL This patch introduces a can=5Fsleep parameter into the wd719x=5Fchip=5Finit() function. When we have spinlock and can't sleep, we pass in 0; in other cases, we pass in 1. Signed-off-by: Wen Yang CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org CC: linux-kernel@vger.kernel.org --- drivers/scsi/wd719x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index 808ba8e952db..e1dac0115947 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -289,7 +289,7 @@ static int wd719x=5Fqueuecommand(struct Scsi=5FHost *sh= , struct scsi=5Fcmnd *cmd) return 0; } =20 -static int wd719x=5Fchip=5Finit(struct wd719x *wd) +static int wd719x=5Fchip=5Finit(struct wd719x *wd, int can=5Fsleep) { int i, ret; u32 risc=5Finit[3]; @@ -318,7 +318,8 @@ static int wd719x=5Fchip=5Finit(struct wd719x *wd) =20 if (!wd->fw=5Fvirt) wd->fw=5Fvirt =3D dma=5Falloc=5Fcoherent(&wd->pdev->dev, wd->fw=5Fsize, - &wd->fw=5Fphys, GFP=5FKERNEL); + &wd->fw=5Fphys, can=5Fsleep ? + GFP=5FKERNEL : GFP=5FATOMIC); if (!wd->fw=5Fvirt) { ret =3D -ENOMEM; goto wd719x=5Finit=5Fend; @@ -510,7 +511,7 @@ static int wd719x=5Fhost=5Freset(struct scsi=5Fcmnd *cm= d) dev=5Finfo(&wd->pdev->dev, "host reset requested\n"); spin=5Flock=5Firqsave(wd->sh->host=5Flock, flags); /* Try to reinit the RISC */ - if (wd719x=5Fchip=5Finit(wd) =3D=3D 0) + if (wd719x=5Fchip=5Finit(wd, 0) =3D=3D 0) result =3D SUCCESS; else result =3D FAILED; @@ -834,7 +835,7 @@ static int wd719x=5Fboard=5Ffound(struct Scsi=5FHost *s= h) /* read parameters from EEPROM */ wd719x=5Fread=5Feeprom(wd); =20 - ret =3D wd719x=5Fchip=5Finit(wd); + ret =3D wd719x=5Fchip=5Finit(wd, 1); if (ret) goto fail=5Ffree=5Firq; =20 --=20 2.19.1