From patchwork Mon Aug 27 10:26:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 10576903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED1AC920 for ; Mon, 27 Aug 2018 10:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D79A129723 for ; Mon, 27 Aug 2018 10:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB6D129729; Mon, 27 Aug 2018 10:31:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4008429723 for ; Mon, 27 Aug 2018 10:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tT88VZGqW6OxnGCQKntJQU+g7i9HkAJ+5UTL/iJ8Y40=; b=UwdZ3epFR5VjqC 9eX+JBllFPSfJueCwGd0Gieqmo3juxxgDG+5mmuswyiJs86tkQ0Ie4B1aVPxMzCGJbwDNeqzBbVqC L1hncrfiCBvqTmbCbIROXVHTKTFJNBafLpTTlIkFSBPvqOf5uHjp57S39U0nzHgntn8doTzgMhvPX XF60y3yOjTWr2UTF1GcrLlNKEk8gG6rypMEZw2Ej6cyO8dAjvCSlw+zgoZHgMhhrq5us2V8zgC8r7 SkJQ/LmgTpjap6kS8KVgzdCh0Xv21hoNchY9sCgje8nzrG2ab4P4ho0ELF1ijWK8uQIiB7oQ9rI8b QZUD28VN9pCUT03Tf0nw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuEo7-0006dV-Ru; Mon, 27 Aug 2018 10:31:39 +0000 Received: from esa6.microchip.iphmx.com ([216.71.154.253]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuEjf-0003VN-RC; Mon, 27 Aug 2018 10:27:07 +0000 X-IronPort-AV: E=Sophos;i="5.53,294,1531810800"; d="scan'208";a="16021296" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Aug 2018 03:26:50 -0700 Received: from localhost.localdomain.com (10.10.76.4) by chn-sv-exch04.mchp-main.com (10.10.76.105) with Microsoft SMTP Server id 14.3.352.0; Mon, 27 Aug 2018 03:26:49 -0700 From: Tudor Ambarus To: , , , , , Subject: [RESEND PATCH v2 0/3] add support to non-uniform SFDP SPI NOR flash memories Date: Mon, 27 Aug 2018 13:26:41 +0300 Message-ID: <20180827102644.7323-1-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.9.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_032704_737871_B0AE712E X-CRM114-Status: GOOD ( 11.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Cristian.Birsan@microchip.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Rebased on spi-nor/next. Backward compatibility test done on mx25l3273fm2i-08g. Non-uniform erase test done on sst26vf064b-104i/sn. Note that in order to do the non-uniform test you'll have to force the spi_nor_has_uniform_erase() to return false, because the erase map is tuned to come back to the uniform case. Also, for the SST flashes, you'll have to unlock the global protection (see https://www.spinics.net/lists/arm-kernel/msg666350.html). Changes in v2: - add JESD216B SFDP optional parsers: Sector Map Parameter Table parser and 4-byte Address Instruction Table parser (patch 2/3 and patch 3/3). - save the Erase Types from bfpt to determine the Erase Type sizes. Sort all the map's Erase Types in ascending order with the smallest erase size being the first member in the erase_type array. Sort in the same way the Erase Type mask in regions in order to have a 1-to-1 correspondence with the Erase Types defined in the map. We sort the Erase Type by size, at init, in order to speed up the process of finding the best erase command at run-time. - remove setting of mtd->erasesize and nor->erase_opcode when parsing the Basic Flash Parameter Table. mtd->erasesize was set to the maximum supported Erase Type size, without verifying if that Erase Type can erase the entire flash. mtd->erasesize is now set just in spi_nor_select_erase(), after we find which Erase Types are supported in the uniform case. - spi_nor_select_erase(): pass directly info->sector_size instead of the whole flash_info structure in order to simplify the code. - fix condition on finding erase regions: while (addr < region_start || addr >= region_end) { - fix the list command adding: list_add_tail() instead of list_add() - write_enable(nor); before erasing the sectors - As Boris suggested, remove likely() because it doesn't make any difference given the time it takes to actually erase the block. - bool return value for spi_nor_has_uniform_erase(). Changes in v1 or what I've done on top of Cyrille's work (https://lkml.org/lkml/2017/4/15/70): - minimize the amount of erase() calls by using the best sequence of erase type commands depending on alignment. - build the list of best fitted erase commands to be executed once we validate that the erase can be performed. - add improvements on how the erase map is handled. The regions are consecutive in the address space, walk through the regions incrementally. - speed up finding the best erase type command. Order erase types by size, iterate them from the biggest to the smallest and stop when best fitted command is found. - determine at init if there are erase types that can erase the entire memory - fix support for overlaid regions. Cyrille Pitchen (1): mtd: spi-nor: parse SFDP 4-byte Address Instruction Table Tudor Ambarus (2): mtd: spi-nor: add support to non-uniform SFDP SPI NOR flash memories mtd: spi-nor: parse SFDP Sector Map Parameter Table drivers/mtd/spi-nor/spi-nor.c | 892 +++++++++++++++++++++++++++++++++++++++--- include/linux/mtd/spi-nor.h | 120 ++++++ 2 files changed, 954 insertions(+), 58 deletions(-)