From patchwork Tue Dec 5 08:47:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120624 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5480372qgn; Tue, 5 Dec 2017 00:48:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMbrpR9aQ70pGWAOZoXdf7MB/tqf35/Nszwnk6EVGE6T+00QsAfWKB1eGqngiIBEc/8O2rk5 X-Received: by 10.99.7.8 with SMTP id 8mr16961521pgh.264.1512463713515; Tue, 05 Dec 2017 00:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512463713; cv=none; d=google.com; s=arc-20160816; b=B/KsHHB8fwUUzDesOvtQVC2H08Ixp0n+tGkHaiRMX7FpQX+ufgy1TkHMhIZLcJpTdo EmBCMXRFxP8NEY8hQrLlpnUvIccjpz4NZZQJeULPwiVkHEgfo0AbTvcIVLO+5pxsvVzX mqzHcVeS/Gy4bzRh435tvdjgUmGwJ/KVimFzOrZaXlPau74JXdiIUqDZ2DLu6w2qWPA4 Gamy7QaOKdgQP23QyuHV1EFrLVPOvK2l32V6IAZuSIjIrbTO8DrqS5QLGdODOW5phW+J 6w2oLTM+Wy75fWykIwqYIr8zckzmCpzd7hK7GNh6r7Se+5NmMFHozsEXqP6Pm88L7r1z Q3vA== 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:message-id:date:subject:to:from:dkim-signature :dkim-filter:dkim-signature:arc-authentication-results; bh=U7R5NA96J/3diu9Zj1+sMLXpFaXcAZnJQItkm/ME1WM=; b=v9OWc65g4sUnLT4dOu0DMBaPG29aE2IgpwRYaN6AvlMbeMH5phrrus1ANppmLQFpNd hCEjLatGR+0CUFtlYQFtStAxqJ8idnq5LrNi/PCLe7XA552vkNMqFAFplploerS+AmL7 UnL7j0m4p0WWYmyOkE4Q68P8oPbQL1ZH6o1o5Jcj6zsITEkQrSj4+xAzJeLAjNIzf8St fAA25I9S0MdAaxF1S/A6eE17kMYla5I6njRguwsR+MPWorE7EMIl1JAG5sAiMuN2e6Rv bdW+NSCCZPEFAOI7XNYnpG3P8vzsgr5J+rkjUVwwSXSZJb19SDI5Q6s1AzvAX4i03ikZ hiqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=kfhA8ghi; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=EHOmt/TU; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.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. [65.50.211.133]) by mx.google.com with ESMTPS id g3si10820743plp.719.2017.12.05.00.48.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2017 00:48:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=kfhA8ghi; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=EHOmt/TU; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.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: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=U7R5NA96J/3diu9Zj1+sMLXpFaXcAZnJQItkm/ME1WM=; b=kfh A8ghiN/NzFboO/b9XQMsY+JNNEXVDdTKH3Kc1FHgAbeRpL0gJBICJvKXp4wYnL8je1NhiDL3DCjXy i1ld0qoOmvrQRIDniPQmNDNEyXhb0gJm97MBp3pzkqhf5nl0DZ1WgsDb1/I9s288OjAlonCqZcmym cdtdvblA2PNKm4gIzVgWah383Vw5/2F0eiSs0NK1ZO5w57fJGnUp1YDQp0C/KFCDo67x/zInxo/EA jjknkyfrWVN7bjKziGgwBE9W5lvgjXjpv5bjoa0hWsA+Cr/n8kvi8w0n/PBzA/xvDxKEPn/Py7rGN ljn8FPVjwQiU8WQ8n4Tg4vpY2LgqbUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eM8tl-00046E-CG; Tue, 05 Dec 2017 08:48:17 +0000 Received: from conuserg-08.nifty.com ([210.131.2.75]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eM8th-000442-BM for linux-mtd@lists.infradead.org; Tue, 05 Dec 2017 08:48:15 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vB58lQkH015545; Tue, 5 Dec 2017 17:47:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vB58lQkH015545 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512463647; bh=W8P2u/6y3oBRSQjuone9CcHGbMwxJH5iqZmn6UPPPlU=; h=From:To:Cc:Subject:Date:From; b=EHOmt/TUBVvBpRo6/buFjkIFlNSOmqIBIFOLsxRjlcOiNo3auQltAoDByYja1yfoS wVuffQ+sbxCoP6KDbHHYqNQ2xYn8/Iacec4sUOL0a8USWiqicEPIPY0nZzHLNRwycB pG+OJGpka6A9tn7DlAYGcZTNXn+YZXLmG9t2tDvrln2WdcdvMfQPZR4EtRXB/U1WTb UX5rNCcaG7Tphrts/qHkFBTOOkRtCuge7zCrg4sxdgsNkftT19aYu7pxcB2oKldHhJ Is1NKQDvpZQ98aEmXR77C9N8g+fP6he89559o/bjiNk/sS6qWzWrM+YuKesO7qTtTq n4z9S/9D3PXAw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Boris Brezillon Subject: [PATCH v2 1/3] mtd: nand: cafe: remove use of NAND_OWN_BUFFERS Date: Tue, 5 Dec 2017 17:47:14 +0900 Message-Id: <1512463636-28934-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171205_004813_803811_08D108A3 X-CRM114-Status: GOOD ( 14.61 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Marek Vasut , Richard Weinberger , linux-kernel@vger.kernel.org, Masahiro Yamada , Cyrille Pitchen , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org This driver is the last/only user of NAND_OWN_BUFFERS. Boris suggested to remove this flag. Taking a closer look at this driver, it calls dma_alloc_coherent() for the concatenated area for the DMA bounce buffer + struct nand_buffers, but the latter does not need to be DMA-coherent; cafe_{write,read}_buf simply do memcpy() between buffers when usedma==1. Let's do dma_alloc_coherent() for the DMA bounce buffer in the front, and leave the nand_buffers allocation to nand_scan_tail(), then rip off NAND_OWN_BUFFERS. The magic number, 2112, is still mysterious (hard-coded writesize + oobsize ?), but this is not our main interest. I am keeping it. Suggested-by: Boris Brezillon Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mtd/nand/cafe_nand.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c index bc558c4..add4613 100644 --- a/drivers/mtd/nand/cafe_nand.c +++ b/drivers/mtd/nand/cafe_nand.c @@ -613,7 +613,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, uint32_t ctrl; int err = 0; int old_dma; - struct nand_buffers *nbuf; /* Very old versions shared the same PCI ident for all three functions on the chip. Verify the class too... */ @@ -661,7 +660,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, /* Enable the following for a flash based bad block table */ cafe->nand.bbt_options = NAND_BBT_USE_FLASH; - cafe->nand.options = NAND_OWN_BUFFERS; if (skipbbt) { cafe->nand.options |= NAND_SKIP_BBTSCAN; @@ -731,15 +729,12 @@ static int cafe_nand_probe(struct pci_dev *pdev, if (err) goto out_irq; - cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev, - 2112 + sizeof(struct nand_buffers) + - mtd->writesize + mtd->oobsize, - &cafe->dmaaddr, GFP_KERNEL); + cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev, 2112, + &cafe->dmaaddr, GFP_KERNEL); if (!cafe->dmabuf) { err = -ENOMEM; goto out_irq; } - cafe->nand.buffers = nbuf = (void *)cafe->dmabuf + 2112; /* Set up DMA address */ cafe_writel(cafe, cafe->dmaaddr & 0xffffffff, NAND_DMA_ADDR0); @@ -752,11 +747,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, cafe_dev_dbg(&cafe->pdev->dev, "Set DMA address to %x (virt %p)\n", cafe_readl(cafe, NAND_DMA_ADDR0), cafe->dmabuf); - /* this driver does not need the @ecccalc and @ecccode */ - nbuf->ecccalc = NULL; - nbuf->ecccode = NULL; - nbuf->databuf = (uint8_t *)(nbuf + 1); - /* Restore the DMA flag */ usedma = old_dma; @@ -801,10 +791,7 @@ static int cafe_nand_probe(struct pci_dev *pdev, goto out; out_free_dma: - dma_free_coherent(&cafe->pdev->dev, - 2112 + sizeof(struct nand_buffers) + - mtd->writesize + mtd->oobsize, - cafe->dmabuf, cafe->dmaaddr); + dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); out_irq: /* Disable NAND IRQ in global IRQ mask register */ cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); @@ -829,10 +816,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) nand_release(mtd); free_rs(cafe->rs); pci_iounmap(pdev, cafe->mmio); - dma_free_coherent(&cafe->pdev->dev, - 2112 + sizeof(struct nand_buffers) + - mtd->writesize + mtd->oobsize, - cafe->dmabuf, cafe->dmaaddr); + dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); kfree(cafe); } From patchwork Tue Dec 5 08:47:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120625 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5480404qgn; Tue, 5 Dec 2017 00:48:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMY4fYdtlECiw69zeaZsaC7L1tD2Sd6AlOhQlQp5wQESRs38LrLyv4zdaHlSYbCxmD4IdOHR X-Received: by 10.101.73.74 with SMTP id q10mr16674876pgs.127.1512463715908; Tue, 05 Dec 2017 00:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512463715; cv=none; d=google.com; s=arc-20160816; b=phm2fFGpFsebQfkL40tJ2qL26pKkAcDjUMSa+UAeqSH7DtU9uDJ4S6omg7TvDsSCh3 9QGXT0xsFUnER3lMguorrKl0PJXdxQNUCmHZC1PxE4ltaJQekWBO3NBzCSPJjHWNOcKM JWUY+8x9oVFEkhPMdhNo50sILG3vS8Lyi4ZDfdpCJYYFs5dJ9QmvjyRqTU2ElmY9gUuV aO3Q49DfvqWrE6EVtbaKsyWOmHIhUAXrXiRc5BbqRWwubOFORAcwjIAv486i9t4+w9sP xwxZzHMN8Df02C9Igs6S1IYspjQnSZtCpaPFKmSlTFkLWn/lEtR4c8+KZTQo5IoaM7Rv qJHQ== 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 :arc-authentication-results; bh=c1MH56JUwcksY+wau7TNDkqNyhz/ZhdXnQAA3SObgPk=; b=S1FtsODS5nWMQ3e5mV0POJEXQ63RQ/orLnPUASc5dE1toffQjr98dpRWWlNcU8Qb3A F9j5FMtF8iSo2zZvqZuZkvvfLRYCWaxg6W8dto8Wu6JFh6cGREF6DNh7ON5lT9GAGMMT OjE6ajjR3lsRzhiZs9E/7Mun/EkQt1d46BIu0gFdf69R7oc3HSA9ESq13gt0Fp2mi9DY B3FDJ0FrYZP0zTATLEGzqi+Tixjo9a0HE+7gzSiTHsw8C530B+TKbjvYP27WkUHc5RTC tJv4YoSLke9i9xw7T8GBLIcNtO1yqWpSJ8I2sguK6f19WKusbtoKbuLQPsyRzRjQdtvv ecHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=EhmJWNfA; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=RUQzlTSw; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.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. [65.50.211.133]) by mx.google.com with ESMTPS id f128si8227545pgc.152.2017.12.05.00.48.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2017 00:48:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=EhmJWNfA; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=RUQzlTSw; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.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=c1MH56JUwcksY+wau7TNDkqNyhz/ZhdXnQAA3SObgPk=; b=EhmJWNfAdUN4zY3Dt6PCtsCB7O gC4L8iJJtN1t/KecyP1CxZZ9uXBt4OA82PQ+0zx4P+qtErWN2yUY2LPmu9l5TqwYP6BEzLp/GvYQR BRi0B8GT/lpQ29TFAZb4F2ZxMcghvfUdMHCaxKKVlpWHT7y+UD16fseoyz6+ywNyxblY1GX+eq26A AQJVh75zJwSWFCK6cK/+C4zaWCjD7J0sy3g1TruqnutytPS7uAg879IsSRx/DoXVF3YqruQi43U17 pQ6UIof0TTqjS6IhffI7m1fRvf1kLk6P/i9J+vQsDk0eKrLHyO3kW/txoURrruclzwPo6EjMCmFzq nmd8YU0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eM8tw-0004HQ-M5; Tue, 05 Dec 2017 08:48:28 +0000 Received: from conuserg-08.nifty.com ([210.131.2.75]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eM8th-000443-BK for linux-mtd@lists.infradead.org; Tue, 05 Dec 2017 08:48:15 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vB58lQkI015545; Tue, 5 Dec 2017 17:47:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vB58lQkI015545 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512463648; bh=QTfOHrpmC9LDc8+ZHCSVFaMafJzPaR86IWGWotJuhQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RUQzlTSwuwScaYaxJ2uxiDgdbFAZG0MI07+syeLfZWKjJJ+WFk9aCFqf9zjvzJK8m 4f9yMX9CeJtzdn0ey8zsWIhcux1UP61/XAyir6xMx2Q+C68pxErDuYU0SKu+yyiDd9 XW/BH8aggdQJ+wjiipVbjWVSwrfF+9E2RMkynOq/TrjzdxoQzxLL5ihyb/396MqYfP pD1ghg26WRFsHkhVC0x1qTTuWU1WSLIZ6Go4QPmNi769MFzypJGJr8uDCDEHdU0Ny4 eUUV061UMA/O0zQqkLa4XLdF6Ba5ee4YQhM1lHnSHlzwH3+GpNycQabIFA2KQ6GDhH iGY5O8UOwIyXQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Boris Brezillon Subject: [PATCH v2 2/3] mtd: nand: remove unused NAND_OWN_BUFFERS flag Date: Tue, 5 Dec 2017 17:47:15 +0900 Message-Id: <1512463636-28934-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512463636-28934-1-git-send-email-yamada.masahiro@socionext.com> References: <1512463636-28934-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171205_004813_812268_1F42456E X-CRM114-Status: GOOD ( 12.23 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Marek Vasut , Richard Weinberger , linux-kernel@vger.kernel.org, Masahiro Yamada , Cyrille Pitchen , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The last/only user of NAND_OWN_BUFFERS (cafe_nand.c) has been reworked. This flag is no longer needed. Suggested-by: Boris Brezillon Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mtd/nand/nand_base.c | 45 ++++++++++++++++++++------------------------ include/linux/mtd/rawnand.h | 5 ----- 2 files changed, 20 insertions(+), 30 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 6135d00..0cc61b1 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4646,35 +4646,30 @@ int nand_scan_tail(struct mtd_info *mtd) return -EINVAL; } - if (!(chip->options & NAND_OWN_BUFFERS)) { - nbuf = kzalloc(sizeof(*nbuf), GFP_KERNEL); - if (!nbuf) - return -ENOMEM; - - nbuf->ecccalc = kmalloc(mtd->oobsize, GFP_KERNEL); - if (!nbuf->ecccalc) { - ret = -ENOMEM; - goto err_free_nbuf; - } + nbuf = kzalloc(sizeof(*nbuf), GFP_KERNEL); + if (!nbuf) + return -ENOMEM; - nbuf->ecccode = kmalloc(mtd->oobsize, GFP_KERNEL); - if (!nbuf->ecccode) { - ret = -ENOMEM; - goto err_free_nbuf; - } + nbuf->ecccalc = kmalloc(mtd->oobsize, GFP_KERNEL); + if (!nbuf->ecccalc) { + ret = -ENOMEM; + goto err_free_nbuf; + } - nbuf->databuf = kmalloc(mtd->writesize + mtd->oobsize, - GFP_KERNEL); - if (!nbuf->databuf) { - ret = -ENOMEM; - goto err_free_nbuf; - } + nbuf->ecccode = kmalloc(mtd->oobsize, GFP_KERNEL); + if (!nbuf->ecccode) { + ret = -ENOMEM; + goto err_free_nbuf; + } - chip->buffers = nbuf; - } else if (!chip->buffers) { - return -ENOMEM; + nbuf->databuf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL); + if (!nbuf->databuf) { + ret = -ENOMEM; + goto err_free_nbuf; } + chip->buffers = nbuf; + /* * FIXME: some NAND manufacturer drivers expect the first die to be * selected when manufacturer->init() is called. They should be fixed @@ -5032,7 +5027,7 @@ void nand_cleanup(struct nand_chip *chip) /* Free bad block table memory */ kfree(chip->bbt); - if (!(chip->options & NAND_OWN_BUFFERS) && chip->buffers) { + if (chip->buffers) { kfree(chip->buffers->databuf); kfree(chip->buffers->ecccode); kfree(chip->buffers->ecccalc); diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 749bb08..5b24a8e 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -191,11 +191,6 @@ enum nand_ecc_algo { /* Non chip related options */ /* This option skips the bbt scan during initialization. */ #define NAND_SKIP_BBTSCAN 0x00010000 -/* - * This option is defined if the board driver allocates its own buffers - * (e.g. because it needs them DMA-coherent). - */ -#define NAND_OWN_BUFFERS 0x00020000 /* Chip may not exist, so silence any errors in scan */ #define NAND_SCAN_SILENT_NODEV 0x00040000 /* From patchwork Tue Dec 5 08:47:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120626 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5480960qgn; Tue, 5 Dec 2017 00:49:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMbblqXqFrBeDG+4lkAp9wVoZnDla+GuXDREAMcJIXylVndVmsA2gnP8YysloPEZB+6vlX6x X-Received: by 10.98.63.16 with SMTP id m16mr22505158pfa.218.1512463759725; Tue, 05 Dec 2017 00:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512463759; cv=none; d=google.com; s=arc-20160816; b=v/gpFl/x8ZVCZZv7xxSgKtk2eiYObYqXdQc4iqsSRzJYZEVQccOtFkSSdBcx8oDy0j K/CB7HwZxUNxHILnUsUNVaory5YitN6dV7BfnzknrKwoZHyQ0G2Huxe13Pa46xNkE4Qq 9794xfTBL6HBfrWwCLMslNrIYnUa+9TDq5udqoVXUsSM0faI/sb4imh69D3l5CfdZeqH cj3iPYacPiciVjaFnuWzFc2ZajoVeUFqN2wj8MjaabQX09wLMBaHxZYmkUleJqW8oamy bpQLW6sPH3KDRgjJV6dWM2c4CdSgmahmwLHVkiAm4hpYE+eZyrXPituTsi7XwqFEIGC5 hlcw== 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 :arc-authentication-results; bh=R5P3/Y6YWd2CDdLGKNc+IDh/xCkIrpOSFtCL6OIoNwQ=; b=iePvneA2uZIGn67XurqPmB4RCRtaDJrAr6szHUD3Q9KzRI1d3tFcX5ikzBgbWzba5g jgur0Tx9YkTXrZUwhKi+392fPELw5kITm5gWMchq6v1sTNi20NxFsOhStdk+qj5LRY8o UBpJ4xR/QSZaCX+TOni80YEKmTyK6OlTsTPYhkN1oc/EMv28kBmacvDLZ/BBaDnX7AM4 uJPfSElOwKi0fjsVxJm1DBjc/rfXnyUqoFpS3i+byAVH8KLWB8oD4Bd8fov60/k6utMo KiidOWKaOZvmWWx+4n5Pm0jNuu48qC9o5hItJ0WntSUgQqZPhMKN7sPJmQMm+/w8c/bH qSRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=VrPuV3Tl; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=T5fM9wlZ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.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. [65.50.211.133]) by mx.google.com with ESMTPS id u13si11215692plq.609.2017.12.05.00.49.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2017 00:49:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=VrPuV3Tl; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=T5fM9wlZ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.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=R5P3/Y6YWd2CDdLGKNc+IDh/xCkIrpOSFtCL6OIoNwQ=; b=VrPuV3Tlesza2Gb1e81i1R2ppA W5klVNz3u9BLJvRU43ogQOrkwSPAc9MugDqcyhdECcwKU0T4C7Tb8Y8skqy0E2HkGSXDhhDIzxXQK ZZy9BYBgrDFiP+ADlzy/tmLkmvMcGXE1Y5itK1MCqFgRAbb3su9ZKpeJw6GVKtVKhuE+3XsBBV59U u7g+saQx24jCSmG9zFvQPcTwhChrLyb/5w06/ewnSLnWeGJSoMohVcRV7dUHWmMRDLhnpqId9C+06 5ayEnjBB2WOCPJt9wKrLKcshFxrrwPC+HtPPkmmNs7tDbkWYC1KnOx8KKvm5GjSvw1mz2OG7TzrXu T6+w+LIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eM8ub-0004rq-O5; Tue, 05 Dec 2017 08:49:09 +0000 Received: from conuserg-08.nifty.com ([210.131.2.75]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eM8tr-00044S-1A; Tue, 05 Dec 2017 08:48:31 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vB58lQkJ015545; Tue, 5 Dec 2017 17:47:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vB58lQkJ015545 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512463649; bh=5Beu90NITXAoOdNvnvXJW+8fIWuFjW4MDzh/33tqDyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5fM9wlZx5D6NlTiLcunQLD0WLkBbkEzFBvYNoD9LFHYTm8Qtot7WOTAbwXgZpbOk LgQ36nNKmaRBlYseUUa+uHHWLdntNTcjHEZduwfEo1pXLvHy/Grn4i39noLzAWHB+3 JSAoRrLMlASRR8X0GNLIxpjBfxEu0+Cqji/muvMEZk8UGTwaUugPvKSOrMupQlQtx7 pO/iCDDfEEZRfYIrHgmANmcSQmnV8y8T9x2MkScfiNHNtV4DakSLaOLC/7NFBP1UQc hp8FnpV0QM+qPbUsx14W8F20yzml4OnLvc1O3ll08sP0V239EvX/fYO53cIzzpg6PL X85vgApJFL5cg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Boris Brezillon Subject: [PATCH v2 3/3] mtd: nand: squash struct nand_buffers into struct nand_chip Date: Tue, 5 Dec 2017 17:47:16 +0900 Message-Id: <1512463636-28934-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512463636-28934-1-git-send-email-yamada.masahiro@socionext.com> References: <1512463636-28934-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171205_004824_144554_B09BA530 X-CRM114-Status: GOOD ( 19.06 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Marek Vasut , Richard Weinberger , Kamal Dasu , linux-kernel@vger.kernel.org, Masahiro Yamada , Chen-Yu Tsai , bcm-kernel-feedback-list@broadcom.com, Cyrille Pitchen , Han Xu , Maxime Ripard , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org struct nand_buffers is malloc'ed in nand_scan_tail() just for containing three pointers. Squash this struct into nand_chip. Move and rename as follows: chip->buffers->ecccalc -> chip->ecc.calc_buf chip->buffers->ecccode -> chip->ecc.code_buf chip->buffers->databuf -> chip->data_buf Signed-off-by: Masahiro Yamada --- Changes in v2: - Rename as Boris suggested - Based on cafe_nand rework drivers/mtd/nand/brcmnand/brcmnand.c | 2 +- drivers/mtd/nand/denali.c | 2 +- drivers/mtd/nand/fsmc_nand.c | 4 +- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 4 +- drivers/mtd/nand/nand_base.c | 91 ++++++++++++++-------------------- drivers/mtd/nand/nand_bbt.c | 2 +- drivers/mtd/nand/omap2.c | 10 ++-- drivers/mtd/nand/sunxi_nand.c | 6 +-- include/linux/mtd/rawnand.h | 23 +++------ 9 files changed, 59 insertions(+), 85 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c index e0eb51d..cc13c88 100644 --- a/drivers/mtd/nand/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/brcmnand/brcmnand.c @@ -1681,7 +1681,7 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd, int ret; if (!buf) { - buf = chip->buffers->databuf; + buf = chip->data_buf; /* Invalidate page cache */ chip->pagebuf = -1; } diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 2fc964b..3e61ac4 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -328,7 +328,7 @@ static int denali_check_erased_page(struct mtd_info *mtd, unsigned long uncor_ecc_flags, unsigned int max_bitflips) { - uint8_t *ecc_code = chip->buffers->ecccode; + uint8_t *ecc_code = chip->ecc.code_buf; int ecc_steps = chip->ecc.steps; int ecc_size = chip->ecc.size; int ecc_bytes = chip->ecc.bytes; diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index eac15d9..574b043 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -684,8 +684,8 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; uint8_t *p = buf; - uint8_t *ecc_calc = chip->buffers->ecccalc; - uint8_t *ecc_code = chip->buffers->ecccode; + uint8_t *ecc_calc = chip->ecc.calc_buf; + uint8_t *ecc_code = chip->ecc.code_buf; int off, len, group = 0; /* * ecc_oob is intentionally taken as uint16_t. In 16bit devices, we diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index 50f8d4a..a760ae7 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -1712,7 +1712,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) unsigned int search_area_size_in_strides; unsigned int stride; unsigned int page; - uint8_t *buffer = chip->buffers->databuf; + uint8_t *buffer = chip->data_buf; int saved_chip_number; int found_an_ncb_fingerprint = false; @@ -1771,7 +1771,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this) unsigned int block; unsigned int stride; unsigned int page; - uint8_t *buffer = chip->buffers->databuf; + uint8_t *buffer = chip->data_buf; int saved_chip_number; int status; diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 0cc61b1..fe583e4 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1456,8 +1456,8 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; uint8_t *p = buf; - uint8_t *ecc_calc = chip->buffers->ecccalc; - uint8_t *ecc_code = chip->buffers->ecccode; + uint8_t *ecc_calc = chip->ecc.calc_buf; + uint8_t *ecc_code = chip->ecc.code_buf; unsigned int max_bitflips = 0; chip->ecc.read_page_raw(mtd, chip, buf, 1, page); @@ -1529,7 +1529,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, /* Calculate ECC */ for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) - chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); + chip->ecc.calculate(mtd, p, &chip->ecc.calc_buf[i]); /* * The performance is faster if we position offsets according to @@ -1563,7 +1563,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, chip->read_buf(mtd, &chip->oob_poi[aligned_pos], aligned_len); } - ret = mtd_ooblayout_get_eccbytes(mtd, chip->buffers->ecccode, + ret = mtd_ooblayout_get_eccbytes(mtd, chip->ecc.code_buf, chip->oob_poi, index, eccfrag_len); if (ret) return ret; @@ -1572,13 +1572,13 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) { int stat; - stat = chip->ecc.correct(mtd, p, - &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]); + stat = chip->ecc.correct(mtd, p, &chip->ecc.code_buf[i], + &chip->ecc.calc_buf[i]); if (stat == -EBADMSG && (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { /* check for empty pages with bitflips */ stat = nand_check_erased_ecc_chunk(p, chip->ecc.size, - &chip->buffers->ecccode[i], + &chip->ecc.code_buf[i], chip->ecc.bytes, NULL, 0, chip->ecc.strength); @@ -1611,8 +1611,8 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; uint8_t *p = buf; - uint8_t *ecc_calc = chip->buffers->ecccalc; - uint8_t *ecc_code = chip->buffers->ecccode; + uint8_t *ecc_calc = chip->ecc.calc_buf; + uint8_t *ecc_code = chip->ecc.code_buf; unsigned int max_bitflips = 0; for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { @@ -1674,8 +1674,8 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; uint8_t *p = buf; - uint8_t *ecc_code = chip->buffers->ecccode; - uint8_t *ecc_calc = chip->buffers->ecccalc; + uint8_t *ecc_code = chip->ecc.code_buf; + uint8_t *ecc_calc = chip->ecc.calc_buf; unsigned int max_bitflips = 0; /* Read the OOB area first */ @@ -1894,7 +1894,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, /* Is the current page in the buffer? */ if (realpage != chip->pagebuf || oob) { - bufpoi = use_bufpoi ? chip->buffers->databuf : buf; + bufpoi = use_bufpoi ? chip->data_buf : buf; if (use_bufpoi && aligned) pr_debug("%s: using read bounce buffer for buf@%p\n", @@ -1938,7 +1938,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, /* Invalidate page cache */ chip->pagebuf = -1; } - memcpy(buf, chip->buffers->databuf + col, bytes); + memcpy(buf, chip->data_buf + col, bytes); } if (unlikely(oob)) { @@ -1979,7 +1979,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, buf += bytes; max_bitflips = max_t(unsigned int, max_bitflips, ret); } else { - memcpy(buf, chip->buffers->databuf + col, bytes); + memcpy(buf, chip->data_buf + col, bytes); buf += bytes; max_bitflips = max_t(unsigned int, max_bitflips, chip->pagebuf_bitflips); @@ -2403,7 +2403,7 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, int i, eccsize = chip->ecc.size, ret; int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; - uint8_t *ecc_calc = chip->buffers->ecccalc; + uint8_t *ecc_calc = chip->ecc.calc_buf; const uint8_t *p = buf; /* Software ECC calculation */ @@ -2433,7 +2433,7 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, int i, eccsize = chip->ecc.size, ret; int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; - uint8_t *ecc_calc = chip->buffers->ecccalc; + uint8_t *ecc_calc = chip->ecc.calc_buf; const uint8_t *p = buf; for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { @@ -2469,7 +2469,7 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd, int oob_required, int page) { uint8_t *oob_buf = chip->oob_poi; - uint8_t *ecc_calc = chip->buffers->ecccalc; + uint8_t *ecc_calc = chip->ecc.calc_buf; int ecc_size = chip->ecc.size; int ecc_bytes = chip->ecc.bytes; int ecc_steps = chip->ecc.steps; @@ -2503,7 +2503,7 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd, /* copy calculated ECC for whole page to chip->buffer->oob */ /* this include masked-value(0xFF) for unwritten subpages */ - ecc_calc = chip->buffers->ecccalc; + ecc_calc = chip->ecc.calc_buf; ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0, chip->ecc.total); if (ret) @@ -2737,9 +2737,9 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, if (part_pagewr) bytes = min_t(int, bytes - column, writelen); chip->pagebuf = -1; - memset(chip->buffers->databuf, 0xff, mtd->writesize); - memcpy(&chip->buffers->databuf[column], buf, bytes); - wbuf = chip->buffers->databuf; + memset(chip->data_buf, 0xff, mtd->writesize); + memcpy(&chip->data_buf[column], buf, bytes); + wbuf = chip->data_buf; } if (unlikely(oob)) { @@ -4632,7 +4632,6 @@ int nand_scan_tail(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); struct nand_ecc_ctrl *ecc = &chip->ecc; - struct nand_buffers *nbuf = NULL; int ret, i; /* New bad blocks should be marked in OOB, flash-based BBT, or both */ @@ -4646,30 +4645,22 @@ int nand_scan_tail(struct mtd_info *mtd) return -EINVAL; } - nbuf = kzalloc(sizeof(*nbuf), GFP_KERNEL); - if (!nbuf) + ecc->calc_buf = kmalloc(mtd->oobsize, GFP_KERNEL); + if (!ecc->calc_buf) return -ENOMEM; - nbuf->ecccalc = kmalloc(mtd->oobsize, GFP_KERNEL); - if (!nbuf->ecccalc) { + ecc->code_buf = kmalloc(mtd->oobsize, GFP_KERNEL); + if (!ecc->code_buf) { ret = -ENOMEM; - goto err_free_nbuf; + goto err_free_buf; } - nbuf->ecccode = kmalloc(mtd->oobsize, GFP_KERNEL); - if (!nbuf->ecccode) { + chip->data_buf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL); + if (!chip->data_buf) { ret = -ENOMEM; - goto err_free_nbuf; + goto err_free_buf; } - nbuf->databuf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL); - if (!nbuf->databuf) { - ret = -ENOMEM; - goto err_free_nbuf; - } - - chip->buffers = nbuf; - /* * FIXME: some NAND manufacturer drivers expect the first die to be * selected when manufacturer->init() is called. They should be fixed @@ -4680,10 +4671,10 @@ int nand_scan_tail(struct mtd_info *mtd) ret = nand_manufacturer_init(chip); chip->select_chip(mtd, -1); if (ret) - goto err_free_nbuf; + goto err_free_buf; /* Set the internal oob buffer location, just after the page data */ - chip->oob_poi = chip->buffers->databuf + mtd->writesize; + chip->oob_poi = chip->data_buf + mtd->writesize; /* * If no default placement scheme is given, select an appropriate one. @@ -4969,13 +4960,10 @@ int nand_scan_tail(struct mtd_info *mtd) err_nand_manuf_cleanup: nand_manufacturer_cleanup(chip); -err_free_nbuf: - if (nbuf) { - kfree(nbuf->databuf); - kfree(nbuf->ecccode); - kfree(nbuf->ecccalc); - kfree(nbuf); - } +err_free_buf: + kfree(chip->data_buf); + kfree(ecc->code_buf); + kfree(ecc->calc_buf); return ret; } @@ -5027,12 +5015,9 @@ void nand_cleanup(struct nand_chip *chip) /* Free bad block table memory */ kfree(chip->bbt); - if (chip->buffers) { - kfree(chip->buffers->databuf); - kfree(chip->buffers->ecccode); - kfree(chip->buffers->ecccalc); - kfree(chip->buffers); - } + kfree(chip->data_buf); + kfree(chip->ecc.code_buf); + kfree(chip->ecc.calc_buf); /* Free bad block descriptor memory */ if (chip->badblock_pattern && chip->badblock_pattern->options diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 2915b67..3609285 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -898,7 +898,7 @@ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *b { struct nand_chip *this = mtd_to_nand(mtd); - return create_bbt(mtd, this->buffers->databuf, bd, -1); + return create_bbt(mtd, this->data_buf, bd, -1); } /** diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index dad438c..7870cb1 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -1530,7 +1530,7 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { int ret; - uint8_t *ecc_calc = chip->buffers->ecccalc; + uint8_t *ecc_calc = chip->ecccalc; /* Enable GPMC ecc engine */ chip->ecc.hwctl(mtd, NAND_ECC_WRITE); @@ -1568,7 +1568,7 @@ static int omap_write_subpage_bch(struct mtd_info *mtd, u32 data_len, const u8 *buf, int oob_required, int page) { - u8 *ecc_calc = chip->buffers->ecccalc; + u8 *ecc_calc = chip->ecccalc; int ecc_size = chip->ecc.size; int ecc_bytes = chip->ecc.bytes; int ecc_steps = chip->ecc.steps; @@ -1605,7 +1605,7 @@ static int omap_write_subpage_bch(struct mtd_info *mtd, /* copy calculated ECC for whole page to chip->buffer->oob */ /* this include masked-value(0xFF) for unwritten subpages */ - ecc_calc = chip->buffers->ecccalc; + ecc_calc = chip->ecccalc; ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0, chip->ecc.total); if (ret) @@ -1635,8 +1635,8 @@ static int omap_write_subpage_bch(struct mtd_info *mtd, static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - uint8_t *ecc_calc = chip->buffers->ecccalc; - uint8_t *ecc_code = chip->buffers->ecccode; + uint8_t *ecc_calc = chip->ecccalc; + uint8_t *ecc_code = chip->ecccode; int stat, ret; unsigned int max_bitflips = 0; diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 82244be..9fe5994 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1544,7 +1544,7 @@ static int sunxi_nfc_hw_common_ecc_read_oob(struct mtd_info *mtd, chip->pagebuf = -1; - return chip->ecc.read_page(mtd, chip, chip->buffers->databuf, 1, page); + return chip->ecc.read_page(mtd, chip, chip->data_buf, 1, page); } static int sunxi_nfc_hw_common_ecc_write_oob(struct mtd_info *mtd, @@ -1557,8 +1557,8 @@ static int sunxi_nfc_hw_common_ecc_write_oob(struct mtd_info *mtd, chip->pagebuf = -1; - memset(chip->buffers->databuf, 0xff, mtd->writesize); - ret = chip->ecc.write_page(mtd, chip, chip->buffers->databuf, 1, page); + memset(chip->data_buf, 0xff, mtd->writesize); + ret = chip->ecc.write_page(mtd, chip, chip->data_buf, 1, page); if (ret) return ret; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 5b24a8e..254f847 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -520,6 +520,8 @@ static const struct nand_ecc_caps __name = { \ * @postpad: padding information for syndrome based ECC generators * @options: ECC specific options (see NAND_ECC_XXX flags defined above) * @priv: pointer to private ECC control data + * @calc_buf: buffer for calculated ECC, size is oobsize. + * @code_buf: buffer for ECC read from flash, size is oobsize. * @hwctl: function to control hardware ECC generator. Must only * be provided if an hardware ECC is available * @calculate: function for ECC calculation or readback from ECC hardware @@ -570,6 +572,8 @@ struct nand_ecc_ctrl { int postpad; unsigned int options; void *priv; + u8 *calc_buf; + u8 *code_buf; void (*hwctl)(struct mtd_info *mtd, int mode); int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, uint8_t *ecc_code); @@ -603,21 +607,6 @@ static inline int nand_standard_page_accessors(struct nand_ecc_ctrl *ecc) } /** - * struct nand_buffers - buffer structure for read/write - * @ecccalc: buffer pointer for calculated ECC, size is oobsize. - * @ecccode: buffer pointer for ECC read from flash, size is oobsize. - * @databuf: buffer pointer for data, size is (page size + oobsize). - * - * Do not change the order of buffers. databuf and oobrbuf must be in - * consecutive order. - */ -struct nand_buffers { - uint8_t *ecccalc; - uint8_t *ecccode; - uint8_t *databuf; -}; - -/** * struct nand_sdr_timings - SDR NAND chip timings * * This struct defines the timing requirements of a SDR NAND chip. @@ -785,7 +774,6 @@ struct nand_manufacturer_ops { * @setup_read_retry: [FLASHSPECIFIC] flash (vendor) specific function for * setting the read-retry mode. Mostly needed for MLC NAND. * @ecc: [BOARDSPECIFIC] ECC control structure - * @buffers: buffer structure for read/write * @buf_align: minimum buffer alignment required by a platform * @hwcontrol: platform-specific hardware control structure * @erase: [REPLACEABLE] erase function @@ -825,6 +813,7 @@ struct nand_manufacturer_ops { * @numchips: [INTERN] number of physical chips * @chipsize: [INTERN] the size of one chip for multichip arrays * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 + * @data_buf: [INTERN] buffer for data, size is (page size + oobsize). * @pagebuf: [INTERN] holds the pagenumber which is currently in * data_buf. * @pagebuf_bitflips: [INTERN] holds the bitflip count for the page which is @@ -903,6 +892,7 @@ struct nand_chip { int numchips; uint64_t chipsize; int pagemask; + u8 *data_buf; int pagebuf; unsigned int pagebuf_bitflips; int subpagesize; @@ -933,7 +923,6 @@ struct nand_chip { struct nand_hw_control *controller; struct nand_ecc_ctrl ecc; - struct nand_buffers *buffers; unsigned long buf_align; struct nand_hw_control hwcontrol;