Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3396578imj; Tue, 19 Feb 2019 02:49:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IbNR5PQ4Uy2ZEk7VxOao97N3yWxPJIGTYm+bXpX3lrmWDlwznhzvV9mSf4d5nRpSC0efHsV X-Received: by 2002:a17:902:b20e:: with SMTP id t14mr27366609plr.97.1550573391562; Tue, 19 Feb 2019 02:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550573391; cv=none; d=google.com; s=arc-20160816; b=xn3Hc2Y69wirY2cQoCkCxPNriXf3XyMgVPjiOqAElmg14LIzaGhzuhmuph07kEr9a7 HJRz9Mj0oYxgShN0OjnQAZ+g0xPQc4Pmq+PfkYcfGxYebcq1ucNO+Ck0jrSD75p1mZf9 0TyIeuZ/hhyG5of+QqRuthGI5i7ypq3Z16rG5aayxIoesfKhP1um+Xajz+u8ch8NkK5g yD+7LdmS0UlLnvOYuPVueasopbAaf0ZlKUgA4e1AHj8N5L5A7PBbZq1y43GMLsUgKixz RL84v3fMgGPP8gs5DEGx5iaBsrNBcmZx4QdKl3ZVvPInqdphh0rPtYaKbVW6N9fUvAS2 ZzuQ== 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=Ugxj+5ugoXO93HFfI+ke7kC4mLvrCP0exHAqpBuCXlk=; b=g56LkfhauGrI5fk++qR6Rv4trsbsDD2dDSP8UZLNCSoBa1DwpfPOR49w8iRsyE9l0/ je7HVNVTCW8tQeV3LAjG5WxqPxIi9yOuEJ+ozIrqNJpTfDWRV7Ux6GZRVvq3VV2/oxdm Ya69ruScH+zUqVVew7AD1kLVeZHProuXQerxtr5bgcTF8z+oJAXgLxZzOMKVhZZ+jpHi pGgUd0suqdA20nihL110dA7JpXdz4tcSxC8+WwmUsABST0FJBmJb46O4eIagh4D1K/+C XxuQtobqHezmjvljMjdU78gjpgtC7qBFCbVydUyHO66b8BCX3aXfiz/RXCGyMK50Yma4 tUpQ== 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 ck6si19457251plb.298.2019.02.19.02.49.36; Tue, 19 Feb 2019 02:49:51 -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 S1727752AbfBSKsC (ORCPT + 99 others); Tue, 19 Feb 2019 05:48:02 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:38220 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725767AbfBSKsB (ORCPT ); Tue, 19 Feb 2019 05:48:01 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C97AE3D5B3A229CF88B1; Tue, 19 Feb 2019 18:47:59 +0800 (CST) Received: from huawei.com (10.175.104.208) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Tue, 19 Feb 2019 18:47:51 +0800 From: Liu Jian To: , , , , , , , CC: , , Subject: [PATCH v2] cfi: fix deadloop in cfi_cmdset_0002.c do_write_buffer Date: Wed, 20 Feb 2019 04:47:14 +0800 Message-ID: <1550609234-40861-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 Reviewed-by: Tokunori Ikegami --- v1->v2: change git log, put the Fixes tag on a single line 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