From patchwork Fri Oct 22 02:40:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiangsheng Hou X-Patchwork-Id: 12576937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EBADC433F5 for ; Fri, 22 Oct 2021 02:51:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3C3F613A9 for ; Fri, 22 Oct 2021 02:51:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B3C3F613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3tvGRO1PzdLCV3HFbkJ+vvm/JMgIbwKUozq+5ff7n8o=; b=eNsDOjQOGPznw1 4zLB5u5SU6hgJpw6w4oFhE+y/PBA0G1srsIeXHCal6GBp/CoNBfnFNgApVs51C+motaJvoIa0ukqa The53n7ZVJLvSCT9nvoZ1gUAH3IFLfUoABxBUo5xOwNn5R1aU9nguDi+lGlxTEC/tCXNdcZvZCIDB HaeslBbmkB047XweL2Q1mpQNnV2veegkQEQuNT2+r0IkliDm2pYoEmkTiCEugMwvaZfTOykBpHAl0 mSUgQVAFuzemxzkQtyweg2drmZ/vjPRvfnv1QNTnGI0Bog4D0+H00K2ppwpL9/taPf0wV1Kisfcca CprSBJzOtSD7LhvruGIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdke6-009cZT-3S; Fri, 22 Oct 2021 02:51:02 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdkdq-009cXb-Nr; Fri, 22 Oct 2021 02:50:48 +0000 X-UUID: a46d7ec0c59749d684c0d63755b2bf16-20211021 X-UUID: a46d7ec0c59749d684c0d63755b2bf16-20211021 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 751290898; Thu, 21 Oct 2021 19:50:44 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 21 Oct 2021 19:40:51 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Fri, 22 Oct 2021 10:40:49 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 22 Oct 2021 10:40:48 +0800 From: Xiangsheng Hou To: , CC: , , , , , , , , , , , , Subject: [RFC, v3 5/5] mtd: spinand: skip set/get oob data bytes when interleaved case Date: Fri, 22 Oct 2021 10:40:21 +0800 Message-ID: <20211022024021.14665-6-xiangsheng.hou@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022024021.14665-1-xiangsheng.hou@mediatek.com> References: <20211022024021.14665-1-xiangsheng.hou@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211021_195046_810881_DF8AC5D3 X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org For syndrome layout, ECC/free byte in oob layout and main data are interleaved. For this case, it is better to set/get oob data bytes in ECC engine. For MTK ECC engine, although it can auto place data as sector + oob free + oob ecc for one page in pipelined. However, the bad mark will be not fit with nand spec. Therefore, there have bad mark swap operation in ecc engine. But, the swap opeation(between bbm 0xff with 1byte main data) will lead to more one byte than oobavailable. Set oob databytes after bad mark swap will lead to lost one oob free byte. Therefore, just try to modify the spi nand framework for review. And this may be common for the interleaved case. Signed-off-by: Xiangsheng Hou --- drivers/mtd/nand/spi/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 2c8685f1f2fa..32a4707982c5 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -401,7 +401,8 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, req->datalen); if (req->ooblen) { - if (req->mode == MTD_OPS_AUTO_OOB) + if (req->mode == MTD_OPS_AUTO_OOB && + nand->ecc.user_conf.placement != NAND_ECC_PLACEMENT_INTERLEAVED) mtd_ooblayout_get_databytes(mtd, req->oobbuf.in, spinand->oobbuf, req->ooboffs, @@ -442,7 +443,8 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand, req->datalen); if (req->ooblen) { - if (req->mode == MTD_OPS_AUTO_OOB) + if (req->mode == MTD_OPS_AUTO_OOB && + nand->ecc.user_conf.placement != NAND_ECC_PLACEMENT_INTERLEAVED) mtd_ooblayout_set_databytes(mtd, req->oobbuf.out, spinand->oobbuf, req->ooboffs,