From patchwork Fri Feb 8 08:08:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157807 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1663739jaa; Fri, 8 Feb 2019 00:09:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ7PTptGcU+jPOZjQf99DMPuvzSQHpvFQPOq5tTPLEswge3lsj/2zOYJLVhOCChtj0B6Qmk X-Received: by 2002:a62:2fc3:: with SMTP id v186mr20923618pfv.82.1549613385902; Fri, 08 Feb 2019 00:09:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549613385; cv=none; d=google.com; s=arc-20160816; b=sbwbcH6MbURURU59WYMX4IuWnOoT6SgoTuKeda5vFZy6VzUZZzG4bZd6RVDLy8jH7r xuOa2zph6HKbtJP9rgp2EQhE543C9Sg0w2EakzJqe8ki/mcxxomoHoSw1PgjPa5SBCbM u1ZnaQrYycn1wHgU+4TqCcVSkWnhfI3KILlerdA16ekzPPXrXcLrXfHgXUVpOt+vu0uE ncqHNFrg3OJvnww7RpsPd+7hVVtwseZhgDYJ8IKkl+m8T1L9mi9In9RQn4Y3du96TbZm g5dgAvSWthk+5V+9VMw+VjLHE9zYYTl8rWrhVmidKB3pZU/cZxB+4QMJKLyRZZtZqnyK cDOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=E4Ynx7rzpFbS6nhfLPbmrrL5m7+isdH6PzjtK692pzU=; b=hTcRn5REwvhJomvlejoIPQDAVRMPDq9JjeX5orH74fOItubMjRdFrhx5grx1NZTUKn mAAf7lN2dQ2rWTIwxfavtqTDT3+zkuroHj2zFYoPEAZ8MQGIAY1J618ojQITcCa/lkbY enqd4Hul/ekQogFu9XvwiSCvbHgmR+k+iBOhIoGymroxjgEHihs28kUGsaUJR0B1VbdT /6x66MfEJpoeXEn/arn9U5Iw97HPusfHcaQ9NmBurXDr/6kITh2c3yoYb5uA+oo/Du0V UeHvWh6A9wAok8j0IgwXbUEDxk9W1VFiZ+6H4/JPt1NQpVaV5DJX7S72b562Z3WgOO2U LM5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=IQz+kouF; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=2w6dnPKJ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id m2si1207259plt.98.2019.02.08.00.09.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 00:09:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=IQz+kouF; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=2w6dnPKJ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=E4Ynx7rzpFbS6nhfLPbmrrL5m7+isdH6PzjtK692pzU=; b=IQz+kouF8O2kzDW5/f9C7eSlsq b1HLlzbny594aE0L2mdI1ltpCRdEj9lTofaGkCbUOx2Rvd7R8E+eYSrN1Lgj1i4tGsDXaUcQ9N7yR wIunoJOsbaOg6zTF+erHDQ0Tfcl9B5MFyuAmXuAvudeMCSXuly11YGbjwst2Vrd/++Dyp/QfKcy6T nCIo8Zpv2eNSNgef2IB9VUAejyOAJiBEaW0ZKKIAHlWerx6ctVDUBJ/KP91FOUJyQ+ygRXAGE7K7R OTIjQ74+63wdFOQkonUNEw+bjJE4pGH/YdTSoUEUpc+UcFNFz928o+YncJJycdjxGfNdaqYMoOaty TuTPw5dg==; 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 1gs1E7-0006ZY-2f; Fri, 08 Feb 2019 08:09:35 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs1Dt-0006P5-Tr for linux-mtd@lists.infradead.org; Fri, 08 Feb 2019 08:09:24 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x188902A007241; Fri, 8 Feb 2019 17:09:02 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x188902A007241 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549613342; bh=hAnKPUzY6+ZV3pYmmAUTvAeUozse14Cm/LoQa921o4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2w6dnPKJ454zkvny3QGbT2jstAmdlTwB5tY56UbW/7GpKSuWZ8SQDPpSCoeFgHpNj If+DfDk61EhZUkfflEOa5HiPQ+Ks0iAU69IzzP4OzxVkf1yJBJALkZuv4arOG9eO2+ F4V8/NGvdSw9xGqUxIfkZySKD13VgW6gIc9jLkyr4n7oNmHbYM8QE+nQruD6W7ldH5 x+TFumlTdo2oSiDZ3M3PsowAOL1TvcmzfTWPZGXLKFzQnnAj6bDzZMqaAgSrOQ50zL ar0BdP/k7QglsYK8v2ReULUicTk5ST6yE3Sz/wSNi1UZr8XZ3dQvkgc8M/osmbJq/M 9zGy7B8GCO8Mg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH 01/11] mtd: rawnand: denali: use nand_chip pointer more for internal functions Date: Fri, 8 Feb 2019 17:08:45 +0900 Message-Id: <1549613335-30319-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> References: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190208_000922_387602_D08D3823 X-CRM114-Status: GOOD ( 15.12 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [210.131.2.74 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org After the recent refactoring, the NAND driver hooks now take a pointer to nand_chip. Add to_denali() in order to convert (struct nand_chip *) to (struct denali_nand_info *) directly. It is more useful than the current mtd_to_denali(). I changed some helper functions to take (struct nand_chip *). This will avoid pointer conversion back and forth, and ease further development. Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/raw/denali.c | 57 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 25 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 24aeafc..4ac1314 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -47,6 +47,11 @@ static inline struct denali_nand_info *mtd_to_denali(struct mtd_info *mtd) return container_of(mtd_to_nand(mtd), struct denali_nand_info, nand); } +static struct denali_nand_info *to_denali(struct nand_chip *chip) +{ + return container_of(chip, struct denali_nand_info, nand); +} + /* * Direct Addressing - the slave address forms the control information (command * type, bank, block, and page address). The slave data is the actual data to @@ -282,12 +287,12 @@ static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl) denali->host_write(denali, DENALI_BANK(denali) | type, dat); } -static int denali_check_erased_page(struct mtd_info *mtd, - struct nand_chip *chip, uint8_t *buf, +static int denali_check_erased_page(struct nand_chip *chip, + struct denali_nand_info *denali, u8 *buf, unsigned long uncor_ecc_flags, unsigned int max_bitflips) { - struct denali_nand_info *denali = mtd_to_denali(mtd); + struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; uint8_t *ecc_code = chip->oob_poi + denali->oob_skip_bytes; int ecc_steps = chip->ecc.steps; int ecc_size = chip->ecc.size; @@ -303,9 +308,9 @@ static int denali_check_erased_page(struct mtd_info *mtd, NULL, 0, chip->ecc.strength); if (stat < 0) { - mtd->ecc_stats.failed++; + ecc_stats->failed++; } else { - mtd->ecc_stats.corrected += stat; + ecc_stats->corrected += stat; max_bitflips = max_t(unsigned int, max_bitflips, stat); } @@ -316,11 +321,11 @@ static int denali_check_erased_page(struct mtd_info *mtd, return max_bitflips; } -static int denali_hw_ecc_fixup(struct mtd_info *mtd, +static int denali_hw_ecc_fixup(struct nand_chip *chip, struct denali_nand_info *denali, unsigned long *uncor_ecc_flags) { - struct nand_chip *chip = mtd_to_nand(mtd); + struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; int bank = denali->active_bank; uint32_t ecc_cor; unsigned int max_bitflips; @@ -346,16 +351,17 @@ static int denali_hw_ecc_fixup(struct mtd_info *mtd, * Unfortunately, we can not know the total number of corrected bits in * the page. Increase the stats by max_bitflips. (compromised solution) */ - mtd->ecc_stats.corrected += max_bitflips; + ecc_stats->corrected += max_bitflips; return max_bitflips; } -static int denali_sw_ecc_fixup(struct mtd_info *mtd, +static int denali_sw_ecc_fixup(struct nand_chip *chip, struct denali_nand_info *denali, unsigned long *uncor_ecc_flags, uint8_t *buf) { - unsigned int ecc_size = denali->nand.ecc.size; + struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; + unsigned int ecc_size = chip->ecc.size; unsigned int bitflips = 0; unsigned int max_bitflips = 0; uint32_t err_addr, err_cor_info; @@ -404,7 +410,7 @@ static int denali_sw_ecc_fixup(struct mtd_info *mtd, /* correct the ECC error */ flips_in_byte = hweight8(buf[offset] ^ err_cor_value); buf[offset] ^= err_cor_value; - mtd->ecc_stats.corrected += flips_in_byte; + ecc_stats->corrected += flips_in_byte; bitflips += flips_in_byte; max_bitflips = max(max_bitflips, bitflips); @@ -587,9 +593,11 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf, return ret; } -static int denali_data_xfer(struct denali_nand_info *denali, void *buf, - size_t size, int page, int raw, int write) +static int denali_data_xfer(struct nand_chip *chip, void *buf, size_t size, + int page, int raw, int write) { + struct denali_nand_info *denali = to_denali(chip); + iowrite32(raw ? 0 : ECC_ENABLE__FLAG, denali->reg + ECC_ENABLE); iowrite32(raw ? TRANSFER_SPARE_REG__FLAG : 0, denali->reg + TRANSFER_SPARE_REG); @@ -678,7 +686,7 @@ static int denali_read_page_raw(struct nand_chip *chip, uint8_t *buf, size_t size = writesize + oobsize; int ret, i, pos, len; - ret = denali_data_xfer(denali, tmp_buf, size, page, 1, 0); + ret = denali_data_xfer(chip, tmp_buf, size, page, 1, 0); if (ret) return ret; @@ -766,14 +774,14 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf, int stat = 0; int ret; - ret = denali_data_xfer(denali, buf, mtd->writesize, page, 0, 0); + ret = denali_data_xfer(chip, buf, mtd->writesize, page, 0, 0); if (ret && ret != -EBADMSG) return ret; if (denali->caps & DENALI_CAP_HW_ECC_FIXUP) - stat = denali_hw_ecc_fixup(mtd, denali, &uncor_ecc_flags); + stat = denali_hw_ecc_fixup(chip, denali, &uncor_ecc_flags); else if (ret == -EBADMSG) - stat = denali_sw_ecc_fixup(mtd, denali, &uncor_ecc_flags, buf); + stat = denali_sw_ecc_fixup(chip, denali, &uncor_ecc_flags, buf); if (stat < 0) return stat; @@ -783,7 +791,7 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf, if (ret) return ret; - stat = denali_check_erased_page(mtd, chip, buf, + stat = denali_check_erased_page(chip, denali, buf, uncor_ecc_flags, stat); } @@ -866,17 +874,16 @@ static int denali_write_page_raw(struct nand_chip *chip, const uint8_t *buf, memcpy(tmp_buf + size - len, oob, len); } - return denali_data_xfer(denali, tmp_buf, size, page, 1, 1); + return denali_data_xfer(chip, tmp_buf, size, page, 1, 1); } static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { struct mtd_info *mtd = nand_to_mtd(chip); - struct denali_nand_info *denali = mtd_to_denali(mtd); - return denali_data_xfer(denali, (void *)buf, mtd->writesize, - page, 0, 1); + return denali_data_xfer(chip, (void *)buf, mtd->writesize, page, + 0, 1); } static void denali_select_chip(struct nand_chip *chip, int cs) @@ -1092,9 +1099,9 @@ static const struct mtd_ooblayout_ops denali_ooblayout_ops = { .free = denali_ooblayout_free, }; -static int denali_multidev_fixup(struct denali_nand_info *denali) +static int denali_multidev_fixup(struct nand_chip *chip) { - struct nand_chip *chip = &denali->nand; + struct denali_nand_info *denali = to_denali(chip); struct mtd_info *mtd = nand_to_mtd(chip); /* @@ -1222,7 +1229,7 @@ static int denali_attach_chip(struct nand_chip *chip) chip->ecc.read_oob = denali_read_oob; chip->ecc.write_oob = denali_write_oob; - ret = denali_multidev_fixup(denali); + ret = denali_multidev_fixup(chip); if (ret) return ret; From patchwork Fri Feb 8 08:08:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157806 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1663697jaa; Fri, 8 Feb 2019 00:09:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IaVviE98z/MDr3GOwHK089LHkb8zPigivhuqGg4ods8ID7itxy1Eu+LKMTRNyhprHAPAeDt X-Received: by 2002:a63:d34a:: with SMTP id u10mr9038497pgi.301.1549613382497; Fri, 08 Feb 2019 00:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549613382; cv=none; d=google.com; s=arc-20160816; b=seW5NPs++cGOAaUMc0OIu2agnFxr475wg+kHOTPgs4xYD4D7kBhlS7hLB/0KOL5tZq /kg8UW/p0nojtSvBDkpBuGtJvGvtZsUgRr5GPKFNu8gLNumfITE8GRJM58UNOHAz7Tib yTFZV96bxcUZR0+ZcR6I0bAfTeKloavN2nNy28mKoARbYJYdiXhgB1EP6dhapbSCYeFk MkenBB+zptop9fltMt3aeGC0zOv8sXqej1Fy+EtzXlOXMg/9JojuHwXlDn8UPlSJSNKk tQ9eYi8+JSLm4y3nyo6QbvPd36ywhBu/WtkIlQix5yQNTmkWlLJvXlppW/fOzSSJvPb0 8D7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=EKZLckPP8MvHvFBF5d2M2y+z/3moPG3NDCPfQW1swOY=; b=DmOQaBoGEPF5TedXt7x6eBIfN2G+wdN7hP1ww8C7Zu6Cre0jEK003bEpvUvrd9ZgfC tVEFdLILatWkuhJzfp28JPNxX9/yQbhRqcUlfGnGiaugtZuSQoRzByKueVCVqfsJGgqG +BfuoroAHD+pU8AE3bMgywcD498DS+FtaYZfebcsv3qGlmZSWN0XzeCYtz4n3gy9+1wt a9ApDIzpPVEediosPkG6XxX2LDYwS8kLElxJYUAMMZLkuTUlhtVMDx+qoWGmP5JI8Rs5 FwssPDVo7MGKFAKeikuYJJz6FgdwV1oTapNUtDbddIhXth1irOzemO2rKsMKafa/Evc+ Xu2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b="M/zoXX00"; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=WbYVO+gJ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 38si1563564pgx.460.2019.02.08.00.09.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 00:09:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b="M/zoXX00"; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=WbYVO+gJ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=EKZLckPP8MvHvFBF5d2M2y+z/3moPG3NDCPfQW1swOY=; b=M/zoXX00crwImKW3TJQlSSFFHu XG0d6W75oTBYHQDctDuOOtRzPbf/JDApcxMalxoYIP8HDvsMdSVRVBdn1gkgjXLrzgVGeopF0T2hr kfJtebZXos/YA4l2JIgCXDD69ENoz7GWadomHYSkryLvqq6XGf46fVl9e3Z711aNHV2viIGfQggHW PutK8u6NeYqPKI8sSkOcuOmHZ33RB6xqlmyuMRtKO04W0xFzO2Yc6jgP1NsLkV6MyhUHB/AKqxOzw cTXzuHxNy2TNzJMv+67GA295fvNYtDAywh/NZqvTha1JRc1de1DyakBZzZ6Q0ahGEFJujiNvqR01l 6w+WuNfQ==; 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 1gs1Dy-0006R1-GT; Fri, 08 Feb 2019 08:09:26 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs1Dt-0006P0-Tp for linux-mtd@lists.infradead.org; Fri, 08 Feb 2019 08:09:24 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x188902C007241; Fri, 8 Feb 2019 17:09:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x188902C007241 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549613344; bh=rjWhvlUWNUpZmuZcusNgiBwXBwtkYUqY7KvE7yA/mk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WbYVO+gJs3fMimX9FNBAHfPQcXKowrUyv1LaHUTfJhBeZ/5Q5nTTOX9BoZ8dtBZJU XOmylJEXi3cDZcjJFnv0A/mZ+ldwOtrshdWG+df43EyRLrY114e1FGyNNe5DGt1h6m ECN6LZYip3YqkKO1Muh0yzjSwsooP+ES3l5KwAB7A5Rmm+yyg02IMT5spVfZz0PfVP EDrmyISB/Uapqag6Nea9f28CzfItxBgBOhCySA0omwKhkL2no2UCENt+Rw1JzqDyg2 e/6Bg2y9ev28UCSCboA2/PJ8u7yU6Ek2YA2bo4eqccOuryKNkoVRs5/uiYQFgLN1xf uWU/2utAV4qSg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH 03/11] mtd: rawnand: denali: remove unneeded casts in denali_{read, write}_pio Date: Fri, 8 Feb 2019 17:08:47 +0900 Message-Id: <1549613335-30319-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> References: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190208_000922_395140_B86030C7 X-CRM114-Status: GOOD ( 10.21 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [210.131.2.74 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Since (u32 *) can accept an opaque pointer, the explicit casting from (void *) to (u32 *) is redundant. Change the function argument type to remove the casts. Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/raw/denali.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 9287f4f..a2fe2ff 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -478,11 +478,10 @@ static void denali_setup_dma32(struct denali_nand_info *denali, denali->host_write(denali, mode | 0x14000, 0x2400); } -static int denali_pio_read(struct denali_nand_info *denali, void *buf, +static int denali_pio_read(struct denali_nand_info *denali, u32 *buf, size_t size, int page) { u32 addr = DENALI_MAP01 | DENALI_BANK(denali) | page; - uint32_t *buf32 = (uint32_t *)buf; uint32_t irq_status, ecc_err_mask; int i; @@ -494,7 +493,7 @@ static int denali_pio_read(struct denali_nand_info *denali, void *buf, denali_reset_irq(denali); for (i = 0; i < size / 4; i++) - *buf32++ = denali->host_read(denali, addr); + buf[i] = denali->host_read(denali, addr); irq_status = denali_wait_for_irq(denali, INTR__PAGE_XFER_INC); if (!(irq_status & INTR__PAGE_XFER_INC)) @@ -506,18 +505,17 @@ static int denali_pio_read(struct denali_nand_info *denali, void *buf, return irq_status & ecc_err_mask ? -EBADMSG : 0; } -static int denali_pio_write(struct denali_nand_info *denali, - const void *buf, size_t size, int page) +static int denali_pio_write(struct denali_nand_info *denali, const u32 *buf, + size_t size, int page) { u32 addr = DENALI_MAP01 | DENALI_BANK(denali) | page; - const uint32_t *buf32 = (uint32_t *)buf; uint32_t irq_status; int i; denali_reset_irq(denali); for (i = 0; i < size / 4; i++) - denali->host_write(denali, addr, *buf32++); + denali->host_write(denali, addr, buf[i]); irq_status = denali_wait_for_irq(denali, INTR__PROGRAM_COMP | INTR__PROGRAM_FAIL); From patchwork Fri Feb 8 08:08:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157808 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1663888jaa; Fri, 8 Feb 2019 00:09:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IZwWjqN9llfuiH3YR4CPm6oQWKiw7yQbiHg219IdCGgzmwaFmKSWwLJCOKcsqC+oKor3oAO X-Received: by 2002:a17:902:622:: with SMTP id 31mr20961648plg.171.1549613398134; Fri, 08 Feb 2019 00:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549613398; cv=none; d=google.com; s=arc-20160816; b=r2bmpL3k+rJUxDlSZcv17jmCn5SUmDkItw9j7HhruWSzuiltobJpumMqGvxqaC3aFU HDdQxihfdKCsOSQJVSl/uCbAQiP90GeCvrVyEyT/R1KYE0TOiOJQx0EAbRVV0A/jl/z1 nLlR7epewq9cWYLDC+bI1tG1iK82Dj0qfJmHPyCIvC92XiRG5pckR3wMx6oCsrV898z2 vovgdMHBUnLwVYBNL9ODQDO9nMqHpor/AFLWkH1BsKCg0WiW+HSPGk3S9SU9g3Y0mEWL Rd+En4/PkXNnSxLdVOV1qRGZpvWzUoQwAxhiquBDQDkzC1Oe9hO4tE7wqt3qjHxNEkgH bC/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=tsUtuURdtHwwYGDrwT/9nefEig539DP9pzKTSdx0qRw=; b=x6e1tXn2ZqPNJ4PFTACxWjMZXe9mHGNjI/oPoMwMs8yIoueYcBHE4v41sLO94EUHZr K/xz/EvmlR2qaLj0I5ELPfdDg31G8UEyyej1cRnRKDjvzozX7gkvZuyn4wuxP1/kgIz5 JZOcdVSd2aDbfGRWYRlH9mozA9HlTi1OFaYs5LBBcxwoCsCMMmBvqKLygq1BScMyrqWs gXUxskz462UJ+lRar2xqESdvS6n/43V1nT949nT2U1ZQ2XYA5TznBQIB5AEmPSJlzJZm CCu+1yN3ufIyeiWKIf1nPWOPfkhzyTd3mn6DaMzqhDc58N+BOHHtSmvWeOVZUuR+c716 UcLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=hAxydVHf; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="XUv/j8h0"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id z63si1591557pfz.132.2019.02.08.00.09.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 00:09:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=hAxydVHf; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="XUv/j8h0"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=tsUtuURdtHwwYGDrwT/9nefEig539DP9pzKTSdx0qRw=; b=hAxydVHfEjmn9ChiriYyeNxcNp 05Gs+eT+qB4ZrzjM4BwESuubxrkgb81sakkeaSDQZc/9FPsvW1FHs5A6OgE0B2RRO+PylKHMIYcaP qVjTML4tx9k6wmVitnE/l6Vej81t+x4jkqP7LT0BwIN0I6BRJFtJ6cY4iUzoILp0YNRAXWHoYoeXF 9qSMKyUryZS9Q7WAUrDow6wo3gYE+GOH103qmM1dg+H2NilwG6nkPFUoknUqp7/xZMP9cW14VlB4x 9CX5+VanjuMzcGDLH1lXMFs4Svmew+9bJPLcNu4BrMx31QRb1Yz/cnvNNudA3GgRdImqCgsUNNAWE FdnWxV9w==; 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 1gs1EJ-0006nu-Hb; Fri, 08 Feb 2019 08:09:47 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs1Dt-0006P3-Tq for linux-mtd@lists.infradead.org; Fri, 08 Feb 2019 08:09:26 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x188902D007241; Fri, 8 Feb 2019 17:09:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x188902D007241 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549613345; bh=UecdNgxlZSCrcUEpr8T6/vLz+DofOS/3xs4XQt8ynaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XUv/j8h0UwTUE4rDIKtLEM3IJ4SkKX2XSW1RLNylZQpC/PzeLFLQA7RdbnJqeRJCP vyY03BhFcxaE04oU2fLzHzgUchVr/Dkh62SGJ0KZMhkS+2jZ8stkbGUC5rZneHP+E4 4mdFGJu57MOAbOVotvMSNI/TxVkA9P+jjAgVwmd2/m3/HQrtRptLPbfyD1YfOqq2q3 NqD51CZRYfdOWamF4sQVALZivsWJ6hAJpn8Cb7QU+OM1Q6+0ETGmWVKXDM/ZCy6qxx 54cBxTICezVxmcawNAaGtFlmx6dcBkhKoE19dmnBoA9kOvpI/xiiQdJKjI0GHLmNU4 brkuEdfXOKLmg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH 04/11] mtd: rawnand: denali: switch over to ->exec_op() from legacy hooks Date: Fri, 8 Feb 2019 17:08:48 +0900 Message-Id: <1549613335-30319-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> References: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190208_000922_392622_B830053E X-CRM114-Status: GOOD ( 16.71 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [210.131.2.74 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Implement ->exec_op(). Remove the deprecated select_chip(), read_byte(), write_byte(), cmd_ctrl(), and waitfunc(). Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/raw/denali.c | 234 +++++++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 108 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index a2fe2ff..bd7df25 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -206,85 +206,11 @@ static uint32_t denali_wait_for_irq(struct denali_nand_info *denali, return denali->irq_status; } -static void denali_read_buf(struct nand_chip *chip, uint8_t *buf, int len) +static void denali_select_target(struct nand_chip *chip, int cs) { - struct mtd_info *mtd = nand_to_mtd(chip); - struct denali_nand_info *denali = mtd_to_denali(mtd); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - int i; - - for (i = 0; i < len; i++) - buf[i] = denali->host_read(denali, addr); -} - -static void denali_write_buf(struct nand_chip *chip, const uint8_t *buf, - int len) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - int i; - - for (i = 0; i < len; i++) - denali->host_write(denali, addr, buf[i]); -} - -static void denali_read_buf16(struct nand_chip *chip, uint8_t *buf, int len) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - uint16_t *buf16 = (uint16_t *)buf; - int i; - - for (i = 0; i < len / 2; i++) - buf16[i] = denali->host_read(denali, addr); -} - -static void denali_write_buf16(struct nand_chip *chip, const uint8_t *buf, - int len) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - const uint16_t *buf16 = (const uint16_t *)buf; - int i; - - for (i = 0; i < len / 2; i++) - denali->host_write(denali, addr, buf16[i]); -} - -static uint8_t denali_read_byte(struct nand_chip *chip) -{ - uint8_t byte; - - denali_read_buf(chip, &byte, 1); - - return byte; -} - -static void denali_write_byte(struct nand_chip *chip, uint8_t byte) -{ - denali_write_buf(chip, &byte, 1); -} - -static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - uint32_t type; - - if (ctrl & NAND_CLE) - type = DENALI_MAP11_CMD; - else if (ctrl & NAND_ALE) - type = DENALI_MAP11_ADDR; - else - return; - - /* - * Some commands are followed by chip->legacy.waitfunc. - * irq_status must be cleared here to catch the R/B# interrupt later. - */ - if (ctrl & NAND_CTRL_CHANGE) - denali_reset_irq(denali); + struct denali_nand_info *denali = to_denali(chip); - denali->host_write(denali, DENALI_BANK(denali) | type, dat); + denali->active_bank = cs; } static int denali_check_erased_page(struct nand_chip *chip, @@ -596,6 +522,8 @@ static int denali_data_xfer(struct nand_chip *chip, void *buf, size_t size, { struct denali_nand_info *denali = to_denali(chip); + denali_select_target(chip, chip->cur_cs); + iowrite32(raw ? 0 : ECC_ENABLE__FLAG, denali->reg + ECC_ENABLE); iowrite32(raw ? TRANSFER_SPARE_REG__FLAG : 0, denali->reg + TRANSFER_SPARE_REG); @@ -856,24 +784,6 @@ static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, 0, 1); } -static void denali_select_chip(struct nand_chip *chip, int cs) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - - denali->active_bank = cs; -} - -static int denali_waitfunc(struct nand_chip *chip) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - uint32_t irq_status; - - /* R/B# pin transitioned from low to high? */ - irq_status = denali_wait_for_irq(denali, INTR__INT_ACT); - - return irq_status & INTR__INT_ACT ? 0 : NAND_STATUS_FAIL; -} - static int denali_setup_data_interface(struct nand_chip *chip, int chipnr, const struct nand_data_interface *conf) { @@ -1185,13 +1095,6 @@ static int denali_attach_chip(struct nand_chip *chip) mtd_set_ooblayout(mtd, &denali_ooblayout_ops); - if (chip->options & NAND_BUSWIDTH_16) { - chip->legacy.read_buf = denali_read_buf16; - chip->legacy.write_buf = denali_write_buf16; - } else { - chip->legacy.read_buf = denali_read_buf; - chip->legacy.write_buf = denali_write_buf; - } chip->ecc.read_page = denali_read_page; chip->ecc.read_page_raw = denali_read_page_raw; chip->ecc.write_page = denali_write_page; @@ -1223,9 +1126,130 @@ static void denali_detach_chip(struct nand_chip *chip) kfree(denali->buf); } +static void denali_exec_in8(struct denali_nand_info *denali, u32 type, + u8 *buf, unsigned int len) +{ + int i; + + for (i = 0; i < len; i++) + buf[i] = denali->host_read(denali, type | DENALI_BANK(denali)); +} + +static void denali_exec_in16(struct denali_nand_info *denali, u32 type, + u8 *buf, unsigned int len) +{ + u32 data; + int i; + + for (i = 0; i < len; i += 2) { + data = denali->host_read(denali, type | DENALI_BANK(denali)); + /* bit 31:24 and 15:8 are used for DDR */ + buf[i] = data >> 16; + buf[i + 1] = data; + } +} + +static void denali_exec_out8(struct denali_nand_info *denali, u32 type, + const u8 *buf, unsigned int len) +{ + int i; + + for (i = 0; i < len; i++) + denali->host_write(denali, type | DENALI_BANK(denali), buf[i]); +} + +static void denali_exec_out16(struct denali_nand_info *denali, u32 type, + const u8 *buf, unsigned int len) +{ + int i; + + for (i = 0; i < len; i += 2) + denali->host_write(denali, type | DENALI_BANK(denali), + buf[i + 1] << 16 | buf[i]); +} + +static int denali_exec_waitrdy(struct denali_nand_info *denali) +{ + u32 irq_stat; + + /* R/B# pin transitioned from low to high? */ + irq_stat = denali_wait_for_irq(denali, INTR__INT_ACT); + + /* Just in case nand_operation has multiple NAND_OP_WAITRDY_INSTR. */ + denali_reset_irq(denali); + + return irq_stat & INTR__INT_ACT ? 0 : -EIO; +} + +static int denali_exec_instr(struct nand_chip *chip, + const struct nand_op_instr *instr) +{ + struct denali_nand_info *denali = to_denali(chip); + bool width16 = chip->options & NAND_BUSWIDTH_16; + + switch (instr->type) { + case NAND_OP_CMD_INSTR: + denali_exec_out8(denali, DENALI_MAP11_CMD, + &instr->ctx.cmd.opcode, 1); + return 0; + case NAND_OP_ADDR_INSTR: + denali_exec_out8(denali, DENALI_MAP11_ADDR, + instr->ctx.addr.addrs, + instr->ctx.addr.naddrs); + return 0; + case NAND_OP_DATA_IN_INSTR: + (!instr->ctx.data.force_8bit && width16 ? + denali_exec_in16 : + denali_exec_in8)(denali, DENALI_MAP11_DATA, + instr->ctx.data.buf.in, + instr->ctx.data.len); + return 0; + case NAND_OP_DATA_OUT_INSTR: + (!instr->ctx.data.force_8bit && width16 ? + denali_exec_out16 : + denali_exec_out8)(denali, DENALI_MAP11_DATA, + instr->ctx.data.buf.out, + instr->ctx.data.len); + return 0; + case NAND_OP_WAITRDY_INSTR: + return denali_exec_waitrdy(denali); + default: + WARN_ONCE(1, "unsupported NAND instruction type: %d\n", + instr->type); + + return -EINVAL; + } +} + +static int denali_exec_op(struct nand_chip *chip, + const struct nand_operation *op, bool check_only) +{ + int i, ret; + + if (check_only) + return 0; + + denali_select_target(chip, op->cs); + + /* + * Some commands contain NAND_OP_WAITRDY_INSTR. + * irq must be cleared here to catch the R/B# interrupt there. + */ + denali_reset_irq(to_denali(chip)); + + for (i = 0; i < op->ninstrs; i++) { + ret = denali_exec_instr(chip, &op->instrs[i]); + if (ret) + return ret; + } + + return 0; +} + static const struct nand_controller_ops denali_controller_ops = { .attach_chip = denali_attach_chip, .detach_chip = denali_detach_chip, + .exec_op = denali_exec_op, .setup_data_interface = denali_setup_data_interface, }; @@ -1260,12 +1284,6 @@ int denali_init(struct denali_nand_info *denali) if (!mtd->name) mtd->name = "denali-nand"; - chip->legacy.select_chip = denali_select_chip; - chip->legacy.read_byte = denali_read_byte; - chip->legacy.write_byte = denali_write_byte; - chip->legacy.cmd_ctrl = denali_cmd_ctrl; - chip->legacy.waitfunc = denali_waitfunc; - if (features & FEATURES__INDEX_ADDR) { denali->host_read = denali_indexed_read; denali->host_write = denali_indexed_write; From patchwork Fri Feb 8 08:08:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157809 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1663991jaa; Fri, 8 Feb 2019 00:10:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IYYblGZHynMHK87uiitIIQnGdvWfk3VDlSPJf0o5cOaWvpsILbLQ2d+p18UZqKem4XDUvLH X-Received: by 2002:a62:4641:: with SMTP id t62mr20706317pfa.141.1549613406282; Fri, 08 Feb 2019 00:10:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549613406; cv=none; d=google.com; s=arc-20160816; b=P2sqfE/HqjP8tjGxWSjdddyEkej4txaqxSMCWdvfPaF6DjTiWE4KqmHycVhKGsPdM4 wVsWUoOC1udsoflSV7qhkzdORuYz6W5e3CEJuj05FNtrMPKZ7FI9m8KnCmI1U2Vm8IZc TEbTrXgS/rkwiBiox5aOCFgSLz4MuwqgUPG7vii9TEoheRkWGP18HfbxRJvewiZ4/Ne6 FfSWh9AK/KZiAa1nCwbVOMvnZKedKOLfyMhMgoVbKVnNM1ZHSCMx4gqzvg9FTBnHmoa3 7nW6ApMsWL9DKLOvWR66cKrrqeMViIon6PXuelt7KqU9wOI3AqxoVIzk835W7oVz4p0y dgOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=e0uVoFIFE7fjivFr4ylsvJopTbLmYjPMueGf+deXLh0=; b=WWUEk+x6VWANXO45vWls8rbCL0JA0tmTSCgqhtKy1PAXDlkgKmI9OuuQKnTkVFLTDa LQHuTu2USjMlgkt38p8rX3cSnjSOOaYMmHyISsaMQs2+tbx0PcEDBx+1ChE0IqevWrs/ dYBmlo5nU32/WByaKL5YhNpWCuw7BdrgP8MiwihJSxtcu5BbA9xQmtkKeur4YdzlCuj6 3x6z6/PaviVJo9ZQjn2a/x0dg0dt50LXRn/PxEFm+xLQ4ZVMiMHhR9YSnbCcgEj9BtiA 5cZ3mc55aYWFj7JlVX5xycihEWbYYWKqyMX/DCM1TmGkDuRdVIJcMEBd78LjThySsO+W lvZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=nqkprOjJ; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="E/cAtWmy"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id x128si1618058pfb.128.2019.02.08.00.10.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 00:10:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=nqkprOjJ; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="E/cAtWmy"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=e0uVoFIFE7fjivFr4ylsvJopTbLmYjPMueGf+deXLh0=; b=nqkprOjJwiMaC9pfRu/EZmkHsJ Al7IPmhwmtst0jzF0OWskNiEBitYRxo2dKxrxr2UrShzTpXrKpQAdPhq7a7S5k8bRlZ41/3Ghgb7E qVYHFKFw2IfRl+ecTDr23zxzvFEbLijBEdB3kpBL0hxFav6Z9JzQgzCNCltJkLTCmNw666GPFYg+q BmFldzlFhWbJt5C6D6r1QwXeGgihLIp6/OgVnQF6IB7SidjsQ3HaZpZdzEvimPvGNSzsLyPNGfsaO OjC7RZD0xNaRrlnU2dRncwCQcgFV93FbYHOJ4mfbvQRdDqneMw/S91Boaxsh4i8eYr+kgZGTDfPSM 1d/P8E+A==; 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 1gs1EV-00072e-R3; Fri, 08 Feb 2019 08:09:59 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs1Dt-0006P1-Tt for linux-mtd@lists.infradead.org; Fri, 08 Feb 2019 08:09:26 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x188902F007241; Fri, 8 Feb 2019 17:09:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x188902F007241 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549613347; bh=ys+VaiSONmRbjGmiyqILt6uJVydiMxaORBDyTleTud4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E/cAtWmyNYyatM9voK3t9AsjiBBkW2sJIrKE0DmQZMOw3XIZdY6aksGi0ac6dMhh+ LSFyPnvjOPrsUe6iFkoODNvE3QIT5kIbxiaf+XqQTj2dSyENKXhgIUPO3K/NfNFi/W xLW1BHWGxozOevaQ1bFZgb9hzE4sc4khTqw8FgEDRkF3a+IlEov4wXgi/rzYHqxLeo op6oIjBkIao9OACBDZH9uozyGwisFAKt9wKMpR+fOEX+wAZ4FlOxIH2ckVdu1z72D4 ueJ04aXyZFHF0GptruHjdgQuDyqWhnlx01zOqXRTfLusN5KmiffnPAZ0fAQAsTx1WG Z+2wEdUOQf76A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH 06/11] mtd: rawnand: denali: use more precise timeout for NAND_OP_WAITRDT_INSTR Date: Fri, 8 Feb 2019 17:08:50 +0900 Message-Id: <1549613335-30319-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> References: <1549613335-30319-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190208_000922_399943_1E9A251C X-CRM114-Status: GOOD ( 12.42 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [210.131.2.74 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Currently, wait_for_completion_timeout() is always passed in the hard-coded msec_to_jiffies(1000). There is no specific reason for 1000 msec, but I just chose it long enough. With the exec_op() conversion, NAND_OP_WAITRDY_INSTR provides more precise timeout value, depending on the preceding command. Let's use it to bail out earlier in error case. I am still keeping the hard-coded values for other higher level hooks such as page_read, page_write, etc. We know the value of tR, tPROG, but we have unknowledge about the data transfer speed of the DMA engine. Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/raw/denali.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 9e63cbd..514d189 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -176,7 +176,7 @@ static void denali_reset_irq(struct denali_nand_info *denali) } static uint32_t denali_wait_for_irq(struct denali_nand_info *denali, - uint32_t irq_mask) + u32 irq_mask, unsigned int timeout_ms) { unsigned long time_left, flags; u32 irq_stat; @@ -196,7 +196,7 @@ static uint32_t denali_wait_for_irq(struct denali_nand_info *denali, spin_unlock_irqrestore(&denali->irq_lock, flags); time_left = wait_for_completion_timeout(&denali->complete, - msecs_to_jiffies(1000)); + msecs_to_jiffies(timeout_ms)); if (!time_left) { dev_err(denali->dev, "timeout while waiting for irq 0x%x\n", irq_mask); @@ -349,7 +349,7 @@ static int denali_sw_ecc_fixup(struct nand_chip *chip, * Once handle all ECC errors, controller will trigger an * ECC_TRANSACTION_DONE interrupt. */ - irq_stat = denali_wait_for_irq(denali, INTR__ECC_TRANSACTION_DONE); + irq_stat = denali_wait_for_irq(denali, INTR__ECC_TRANSACTION_DONE, 10); if (!(irq_stat & INTR__ECC_TRANSACTION_DONE)) return -EIO; @@ -421,7 +421,7 @@ static int denali_pio_read(struct denali_nand_info *denali, u32 *buf, for (i = 0; i < size / 4; i++) buf[i] = denali->host_read(denali, addr); - irq_stat = denali_wait_for_irq(denali, INTR__PAGE_XFER_INC); + irq_stat = denali_wait_for_irq(denali, INTR__PAGE_XFER_INC, 10); if (!(irq_stat & INTR__PAGE_XFER_INC)) return -EIO; @@ -444,7 +444,8 @@ static int denali_pio_write(struct denali_nand_info *denali, const u32 *buf, denali->host_write(denali, addr, buf[i]); irq_stat = denali_wait_for_irq(denali, - INTR__PROGRAM_COMP | INTR__PROGRAM_FAIL); + INTR__PROGRAM_COMP | INTR__PROGRAM_FAIL, + 1000); if (!(irq_stat & INTR__PROGRAM_COMP)) return -EIO; @@ -501,7 +502,7 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf, denali_reset_irq(denali); denali->setup_dma(denali, dma_addr, page, write); - irq_stat = denali_wait_for_irq(denali, irq_mask); + irq_stat = denali_wait_for_irq(denali, irq_mask, 1000); if (!(irq_stat & INTR__DMA_CMD_COMP)) ret = -EIO; else if (irq_stat & ecc_err_mask) @@ -1168,12 +1169,13 @@ static void denali_exec_out16(struct denali_nand_info *denali, u32 type, buf[i + 1] << 16 | buf[i]); } -static int denali_exec_waitrdy(struct denali_nand_info *denali) +static int denali_exec_waitrdy(struct denali_nand_info *denali, + unsigned int timeout_ms) { u32 irq_stat; /* R/B# pin transitioned from low to high? */ - irq_stat = denali_wait_for_irq(denali, INTR__INT_ACT); + irq_stat = denali_wait_for_irq(denali, INTR__INT_ACT, timeout_ms); /* Just in case nand_operation has multiple NAND_OP_WAITRDY_INSTR. */ denali_reset_irq(denali); @@ -1212,7 +1214,8 @@ static int denali_exec_instr(struct nand_chip *chip, instr->ctx.data.len); return 0; case NAND_OP_WAITRDY_INSTR: - return denali_exec_waitrdy(denali); + return denali_exec_waitrdy(denali, + instr->ctx.waitrdy.timeout_ms); default: WARN_ONCE(1, "unsupported NAND instruction type: %d\n", instr->type);