Received: by 10.192.165.148 with SMTP id m20csp1778584imm; Thu, 3 May 2018 05:23:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpogbosqW/BREf+8w108eWaA6T8OJI9udvXstHA+CNocBOw2qQF5vAxRS6uQDPwhRX6MfqB X-Received: by 2002:a17:902:2c83:: with SMTP id n3-v6mr11840350plb.140.1525350220609; Thu, 03 May 2018 05:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525350220; cv=none; d=google.com; s=arc-20160816; b=UqlFs1qgoaycri/iiAq4mvb+6TsRXQ4JeqUjb8PgqVZDUjdBD9mQ4jl2CofKRGSNbK XDuGu3apkFzD8BW8KpWA8tnaQDxEkFceJtl3an24KwaM4yp8Lf9gTKGCpUZn5T1iOpyE 427EFqTSai/WQHHanu5+oxGu4eVgHXm3EGFMaWG3XyeRI6nShDvc5exN0VGOvUgM2z5C FNqelQKBrMOZOi9kTkAgQNSOKaylu2ysvF6ZdyaDTD9x+MFri1ltB741wTvWaybC2WOh HBA2nYJzGCnjaDlivuz3qRscwjrubGn39tysbPq1BTSrdCc0lJhybZRPRFveL4RphJpj 49Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=217aDHf8Zhk2+hDfO4uWEkVDjaOsToKROzNsvEFUhtc=; b=jVc82L4oYXK7386Fn6ErAhJJFYTerQcuGddu/fHtQQ7tKU4bTaAn44358Aey2Ev7+A B0I3Bkvu5Y44iKAoU0/mUDn9racnF5fb8hc5nHPuHT8kHQTWoBt8Zaw8lGvRxkef++v/ tTS+TwzNrBr7qqC2vIoF5bGhxKBSWOh0ZxyxvoCDAMf61c/cBafqX7KLZk5Q7LPQ0d+P i3TdSdqNg/jvQOCrk+R90pK7zDVYCVJ9RiyPrk3LAoFVHEb1z2g9EOr8SWs3c6zo+4LO KsmMGK+/Sja9ZUgoE8E2ouKgRWST8+2D6hbEk3w9EfGF3LgUx4YGywLHokjB5MHTc6Tm diwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=i4Ufxmha; dkim=pass header.i=@codeaurora.org header.s=default header.b=dnwwpzL2; 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 y64si14488091pfj.239.2018.05.03.05.23.26; Thu, 03 May 2018 05:23:40 -0700 (PDT) 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; dkim=pass header.i=@codeaurora.org header.s=default header.b=i4Ufxmha; dkim=pass header.i=@codeaurora.org header.s=default header.b=dnwwpzL2; 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 S1752098AbeECMVx (ORCPT + 99 others); Thu, 3 May 2018 08:21:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42912 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752056AbeECMVu (ORCPT ); Thu, 3 May 2018 08:21:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2F8096090E; Thu, 3 May 2018 12:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525350110; bh=ftTF/WliR3s66EeQVJdWFzttTYKRBEvUu24EeezsBec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4UfxmhaNXbSvcgNM8QQoxYF0cL4JjZt8uQSV279Rfiw9K2nI140xUEFfkZ4KiMwt +NftFgGSgCnI2xQd34hYB/qU/FOYJNg0utFjJ3Wz5Sy7gPjA6pz9972lUbmVCOL8P6 h+5XJ2CuL5HswSsY7yRuPL1KFhch7KjiKbdS2+I0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8638D60591; Thu, 3 May 2018 12:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525350108; bh=ftTF/WliR3s66EeQVJdWFzttTYKRBEvUu24EeezsBec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dnwwpzL2OkThkmQiCv9S7tanwhJzYQd+m13X6deQYmhts203HfiGTKobt7J2BWfxI WXkZFf+cmiwI25Y3TVVfY++q/H76wMzfP9LROUMuKHm5H3290pTmsAqvOBLMmKGl36 e8KHA5CZg+zj2EMRJ6b6onuR3wSQ6BeRnfsw822s= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8638D60591 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Boris Brezillon Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Miquel Raynal , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Andy Gross , Archit Taneja , Abhishek Sahu Subject: [PATCH v2 12/14] mtd: rawnand: qcom: check for operation errors in case of raw read Date: Thu, 3 May 2018 17:50:39 +0530 Message-Id: <1525350041-22995-13-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> References: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there is no error checking for raw read. For raw reads, there won’t be any ECC failure but the operational failures are possible so schedule the NAND_FLASH_STATUS read after each codeword. Signed-off-by: Abhishek Sahu --- * Changes from v1: 1. Removed the code for copy_last_cw. drivers/mtd/nand/raw/qcom_nandc.c | 58 +++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index 10bdc6c..d828115 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -1099,7 +1099,8 @@ static void config_nand_page_read(struct qcom_nand_controller *nandc) * Helper to prepare DMA descriptors for configuring registers * before reading each codeword in NAND page. */ -static void config_nand_cw_read(struct qcom_nand_controller *nandc) +static void +config_nand_cw_read(struct qcom_nand_controller *nandc, bool use_ecc) { if (nandc->props->is_bam) write_reg_dma(nandc, NAND_READ_LOCATION_0, 4, @@ -1108,19 +1109,25 @@ static void config_nand_cw_read(struct qcom_nand_controller *nandc) write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); - read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0); - read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1, - NAND_BAM_NEXT_SGL); + if (use_ecc) { + read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0); + read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1, + NAND_BAM_NEXT_SGL); + } else { + read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + } } /* * Helper to prepare dma descriptors to configure registers needed for reading a * single codeword in page */ -static void config_nand_single_cw_page_read(struct qcom_nand_controller *nandc) +static void +config_nand_single_cw_page_read(struct qcom_nand_controller *nandc, + bool use_ecc) { config_nand_page_read(nandc); - config_nand_cw_read(nandc); + config_nand_cw_read(nandc, use_ecc); } /* @@ -1201,7 +1208,7 @@ static int nandc_param(struct qcom_nand_host *host) nandc->buf_count = 512; memset(nandc->data_buffer, 0xff, nandc->buf_count); - config_nand_single_cw_page_read(nandc); + config_nand_single_cw_page_read(nandc, false); read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, nandc->buf_count, 0); @@ -1565,6 +1572,23 @@ struct read_stats { __le32 erased_cw; }; +/* reads back FLASH_STATUS register set by the controller */ +static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt) +{ + struct nand_chip *chip = &host->chip; + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + int i; + + for (i = 0; i < cw_cnt; i++) { + u32 flash = le32_to_cpu(nandc->reg_read_buf[i]); + + if (flash & (FS_OP_ERR | FS_MPU_ERR)) + return -EIO; + } + + return 0; +} + /* * reads back status registers set by the controller to notify page read * errors. this is equivalent to what 'ecc->correct()' would do. @@ -1731,7 +1755,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, } } - config_nand_cw_read(nandc); + config_nand_cw_read(nandc, true); if (data_buf) read_data_dma(nandc, FLASH_BUF_ACC, data_buf, @@ -1841,7 +1865,7 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, nandc_set_read_loc(nandc, 3, read_loc, oob_size2, 1); } - config_nand_cw_read(nandc); + config_nand_cw_read(nandc, false); read_data_dma(nandc, reg_off, data_buf, data_size1, 0); reg_off += data_size1; @@ -1860,12 +1884,13 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, } ret = submit_descs(nandc); - if (ret) + free_descs(nandc); + if (ret) { dev_err(nandc->dev, "failure to read raw page\n"); + return ret; + } - free_descs(nandc); - - return ret; + return check_flash_errors(host, ecc->steps); } /* implements ecc->read_oob() */ @@ -2085,7 +2110,6 @@ static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs) struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); struct nand_ecc_ctrl *ecc = &chip->ecc; int page, ret, bbpos, bad = 0; - u32 flash_status; u8 *bbm_bytes_buf = chip->data_buf; page = (int)(ofs >> chip->page_shift) & chip->pagemask; @@ -2112,7 +2136,7 @@ static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs) * bbpos offset. */ nandc_set_read_loc(nandc, 0, bbpos, host->bbm_size, 1); - config_nand_single_cw_page_read(nandc); + config_nand_single_cw_page_read(nandc, host->use_ecc); read_data_dma(nandc, FLASH_BUF_ACC + bbpos, bbm_bytes_buf, host->bbm_size, 0); @@ -2123,9 +2147,7 @@ static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs) goto err; } - flash_status = le32_to_cpu(nandc->reg_read_buf[0]); - - if (flash_status & (FS_OP_ERR | FS_MPU_ERR)) { + if (check_flash_errors(host, 1)) { dev_warn(nandc->dev, "error when trying to read BBM\n"); goto err; } -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation