Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbdFEHyt (ORCPT ); Mon, 5 Jun 2017 03:54:49 -0400 Received: from m12-18.163.com ([220.181.12.18]:36182 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751336AbdFEHys (ORCPT ); Mon, 5 Jun 2017 03:54:48 -0400 From: Jia-Ju Bai To: gregkh@linuxfoundation.org, wporter82@gmail.com, sergio.paracuellos@gmail.com, aquannie@gmail.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH V2] staging: rt5208: Fix a sleep-in-atomic bug in xd_copy_page Date: Mon, 5 Jun 2017 15:57:04 +0800 Message-Id: <1496649424-1494-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: EsCowADHM6g8DjVZ4iOUKQ--.25166S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfCw18tFy5ur1xAw45Awb_yoWDZrXE9r 1ktryxXrWUCF9rJr15Cw43K3sFya1F9F4xZa12yFWftrZ8AFZ3AryDZwn8XFyxCF4xGF9r urs5XrySyr9I9jkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU1BWlPUUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiTgDtelUCyNZwrAAAsM Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1095 Lines: 37 The driver may sleep under a spin lock, and the function call path is: rtsx_exclusive_enter_ss (acquire the lock by spin_lock) rtsx_enter_ss rtsx_power_off_card xd_cleanup_work xd_delay_write xd_finish_write xd_copy_page wait_timeout schedule_timeout --> may sleep To fix it, "wait_timeout" is replaced with mdelay in xd_copy_page. Signed-off-by: Jia-Ju Bai --- V2: * Add code explanation in this patch. --- drivers/staging/rts5208/xd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index 85aba05..74d36f9 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -1268,7 +1268,7 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, reg = 0; rtsx_read_register(chip, XD_CTL, ®); if (reg & (XD_ECC1_ERROR | XD_ECC2_ERROR)) { - wait_timeout(100); + mdelay(100); if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { -- 1.7.9.5