Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7140022imu; Thu, 31 Jan 2019 05:42:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Clf/jX1yqmXIeuLdUnHV22nns1lNazi7kP6ec85RT1q2lfseaqq0LXI6FPdChuuly33lv X-Received: by 2002:a17:902:28e6:: with SMTP id f93mr34535326plb.239.1548942148209; Thu, 31 Jan 2019 05:42:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548942148; cv=none; d=google.com; s=arc-20160816; b=byGFBL80OILOdHgSgWLz5zpnTyIfHgym9on4pjpbsxLLVjEHBjeqB0Q8PhS5vXuJsn lchS6gYYLiqVFshnUR3lDRRj2uO2yhOPGK23ItCnCUloj97H7WQPhDE6Bsod4gxeGfml evxCqQ63r5NN7EIwIKl7swQNqacIs1iZypCn+chCe5yGaV6sbgyUwF15M/ABRmnwfirn b5+yrfSEfdTFt24xnXxhEUqkVrT4SBn//byyrDq+UySFRnFdQO+bkhu92hP6KIl9/XFc CgzjcP8jFKw0s9TKNZ3dDzlhYhbuXyrO1xArxqsQPs6yJvZ710BhDkJ2Ki/QMfIVeYCB 2vJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Nnm6YfVHyV7T7kn5Fi0Bcwp9syjSnlcE3GrEjH5TxyU=; b=YF4DI+ZYWwb7RMqP/2QzmvU1fixmlFK7G+Jsnyc8Y0uaxb5cUuin31UbCVtmuqe/Ej EkonWY98DIKajlI8lsOezdESGFD9VhqomDOKPFfU/LdMxTXmaCpfX/2Cr4n4matNXZ4W uP6A54mVGGrTh9Ev9JPF1m0IP5ZhQAvwVw8/PfkmXHpfa6Pst+TR1Ia+pbHQcPTdpnbY 65VpF4An6q8FgSqrxSQ6YJ1S/EMGVKdAGaTqgJ08MwSrnx7/DSXYJcl1CHUlupiVuI4Y UA1npoy9DKsfF6o20/TrUZepuRgp/Tj1It6woK28vQbLY8JIHO5QzRnMN7+YvIaN3Xe/ nmQg== 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 m7si4040392pgi.547.2019.01.31.05.42.03; Thu, 31 Jan 2019 05:42:28 -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 S2387475AbfAaNax (ORCPT + 99 others); Thu, 31 Jan 2019 08:30:53 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:56756 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732271AbfAaNax (ORCPT ); Thu, 31 Jan 2019 08:30:53 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B9C774B4AE423B5AA4DB; Thu, 31 Jan 2019 21:30:48 +0800 (CST) Received: from huawei.com (10.175.104.208) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Thu, 31 Jan 2019 21:30:39 +0800 From: Liu Jian To: , , , , , , , CC: , , Subject: [PATCH] cfi: fix deadloop in cfi_cmdset_0002.c do_write_buffer Date: Fri, 1 Feb 2019 07:30:39 +0800 Message-ID: <1548977439-318904-1-git-send-email-liujian56@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.208] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function do_write_buffer(), in the for loop, there is a case chip_ready() returns 1 while chip_good() returns 0, so it never break the loop. To fix this, chip_good() is enough and it should timeout if it stay bad for a while. Fixes: dfeae1073583(mtd: cfi_cmdset_0002: Change write buffer to check correct value) Signed-off-by: Yi Huaijie Signed-off-by: Liu Jian --- drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 72428b6..818e94b 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1876,14 +1876,14 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, continue; } - if (time_after(jiffies, timeo) && !chip_ready(map, adr)) - break; - if (chip_good(map, adr, datum)) { xip_enable(map, chip, adr); goto op_done; } + if (time_after(jiffies, timeo)) + break; + /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); } -- 2.7.4