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); }