From patchwork Thu Aug 7 01:17:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 377706 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C1EF114012A for ; Thu, 7 Aug 2014 11:22:36 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XFCOP-0003Bp-OM; Thu, 07 Aug 2014 01:21:21 +0000 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XFCOA-0002zb-FF for linux-mtd@lists.infradead.org; Thu, 07 Aug 2014 01:21:06 +0000 Received: by mail-pd0-f177.google.com with SMTP id p10so4185046pdj.8 for ; Wed, 06 Aug 2014 18:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3TsRG9t0F2zIznJdbWDbwVQM1CdMfWJLwLIFxjsuFlA=; b=uuXhbNlX10EMA0zUex2neXF2LhfMxV2KCrYe/k48/IZgSUYDFgeCd2n9fr2Jn/7ucN 89ydKgT+qUCmNlBTio7A6FTmgbPUcEXWsgtEVLraj980oT0hWu4jjbqf5zbGSKGMyaGw I284wmOFc7+YcJQ5YV1RY0z97LSEVXii2FQ929sfNgYp6WJXcnCuO+/QGT0f/END8vJZ VWXRLH/F2i0CxFhyxaKcfLHGMWJ+GY8zR9RrjNs1nv8NlknyiCllyd+rmPwDNr5uIy7U YB/i8/TXTceMiUDGZXrtOwLSXKf9Woa8oK3b84rzX090+gVCuO1sury4q/LX9PIZo/o2 OPCA== X-Received: by 10.67.15.194 with SMTP id fq2mr14278765pad.31.1407374445699; Wed, 06 Aug 2014 18:20:45 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id ct1sm3801242pdb.59.2014.08.06.18.20.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Aug 2014 18:20:45 -0700 (PDT) From: Brian Norris To: Subject: [RFC 8/8] debug: mtd: spi-nor: add BUG_ON() prints to check for !ready Date: Wed, 6 Aug 2014 18:17:02 -0700 Message-Id: <1407374222-8448-9-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1407374222-8448-1-git-send-email-computersforpeace@gmail.com> References: <1407374222-8448-1-git-send-email-computersforpeace@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140806_182106_533824_AEBB4F82 X-CRM114-Status: GOOD ( 10.26 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c02:0:0:0:231 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Cc: Marek Vasut , Huang Shijie , Brian Norris , zajec5@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org I hacked around the wait-till-ready sequencing just now, so let's add some debug checks for now. These probably shouldn't be included in mainline (or at least they should be toned down to something less drastic; WARN_ON() perhaps?). I'm just using these for test purposes. Signed-off-by: Brian Norris --- This patch is really just for testing. I don't think we really need it, although I suppose some form of it couldn't hurt... drivers/mtd/spi-nor/spi-nor.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index d08d9f8bb9bd..c2e53e02fe27 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -226,6 +226,8 @@ static int erase_chip(struct spi_nor *nor) { dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd->size >> 10)); + BUG_ON(spi_nor_ready(nor) <= 0); + return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0, 0); } @@ -278,6 +280,8 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) if (ret) return ret; + BUG_ON(spi_nor_ready(nor) <= 0); + write_enable(nor); /* whole-chip erase? */ @@ -339,6 +343,8 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) if (ret) return ret; + BUG_ON(spi_nor_ready(nor) <= 0); + status_old = read_sr(nor); if (offset < mtd->size - (mtd->size / 2)) @@ -381,6 +387,8 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) if (ret) return ret; + BUG_ON(spi_nor_ready(nor) <= 0); + status_old = read_sr(nor); if (offset+len > mtd->size - (mtd->size / 64)) @@ -678,6 +686,8 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, if (ret) return ret; + BUG_ON(spi_nor_ready(nor) <= 0); + ret = nor->read(nor, from, len, retlen, buf); spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ); @@ -697,6 +707,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) return ret; + BUG_ON(spi_nor_ready(nor) <= 0); + write_enable(nor); nor->sst_write_second = false; @@ -768,6 +780,8 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) return ret; + BUG_ON(spi_nor_ready(nor) <= 0); + write_enable(nor); page_offset = to & (nor->page_size - 1);