From patchwork Tue Nov 21 17:38:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119375 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5569816qgn; Tue, 21 Nov 2017 09:42:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMY+FzcY3GE85r/iOy+Dr/AJDm4tGIqwlBWcv5pThcLw9e4/mqtiS15EWHqd4hlOUmvEonsb X-Received: by 10.80.212.34 with SMTP id t34mr22761455edh.22.1511286171856; Tue, 21 Nov 2017 09:42:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511286171; cv=none; d=google.com; s=arc-20160816; b=dQ6ZApjNAeyNpUv+9IwbvwWJww4Zvv6MJ6US2Dc6wReMsVe7SA/oSeQlE+gZTRMTMt BbRUeaoUD05OUOovuo0419L/QotafskRXb2Fjuf8wI7KiGqCRG8og18vvyl0EDkFjHLj AiIZhf0hWuTQ1piMJEzKteEmnJGRG0W6m9a0K/wa8U7+A6VW/DtQ4Zh3VhRHPN2zPg97 einH0Gagpe1o1FQT2lBEGwIe6NNNuQrxp2YnTVO3AZ/MBwXc57S1TpCmFG2BViuGiBJR 4H/6cFASjmAqvx6pvI484Cu67I0Nwkz8LLegFS29uWEQFrW5H6g1g5T07Z2BIQgvOi0e Mo4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=b/fMlfoIHojAJi8xfDsDxefuMyYyI2l+g4Afq5v6F6o=; b=rGdYJ3NghHGZMASZUeXvkvdvaEDg0EdtfERcGPHXjYVnJ+0NO/xmhyI/ieJUEET2uP SopMvIqxvMrumfWiJTVQAsiRCHeb03Y1wOJloRrCJR3merslpVZoE3Xjc2Jkd8J/rdua s26p8MflgaNlOzI5yv/7wnKUe6v215JhpqKiPqyGeLKi70znH/r0a5kwJnbOnKCWlAXI EYG8CX9zXu3OapBvma9geL1/G8XbsH7rmkmic1VG0tYyLpUrIA2XEde/xPQK7w9q/GOc 0OG5zLkCxhlFdmAJvX2GiQi5vLGn1mlyXvl4NF255GE3g2gvkwShIPLmyeMWh3dBn/kt 44/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=eFX1BMFp; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id m1si1357174edf.525.2017.11.21.09.42.51; Tue, 21 Nov 2017 09:42:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=eFX1BMFp; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 52BB6C21F00; Tue, 21 Nov 2017 17:40:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5A764C21F5B; Tue, 21 Nov 2017 17:39:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8A2CBC21F63; Tue, 21 Nov 2017 17:39:07 +0000 (UTC) Received: from conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) by lists.denx.de (Postfix) with ESMTPS id 98AECC21F69 for ; Tue, 21 Nov 2017 17:39:04 +0000 (UTC) Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id vALHcbu7001225; Wed, 22 Nov 2017 02:38:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com vALHcbu7001225 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511285925; bh=P7UIeRvGD6ISFDmVSxdF+iQFJq1Kmzt0to3lxC/wTmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eFX1BMFpaO2arF4keedIeCgkg8tbuEfpxg223IgikEcV3dIf4DvSwXpuQR72e9n59 Og/7rkBHasFEbIpYZwYuS/eC3qTwLaRaTtOM04sUl2YZduYWN7EI91RyA6AGBQ4BXY JfGO8eeqdR7Q9JyipbgWxJggXEOUsjJWg+Z5QamZmRjVckhbH8vTd/3I2LcVJiFvjH Ei5LKpiCpyFs8uEG6Oeaekq6hx1T6yB8LFTN7nFwEbFM+OvE/kQVOZXHVeFATxct1B EMWULfuccoSZU+OdrxMewL9dsJyHqcSgnKfZYuKL0NDDB3+KFH1a2WaDKlfGL0UAZl 9gCpxXNjx2tDg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 22 Nov 2017 02:38:27 +0900 Message-Id: <1511285912-12452-18-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511285912-12452-1-git-send-email-yamada.masahiro@socionext.com> References: <1511285912-12452-1-git-send-email-yamada.masahiro@socionext.com> Cc: Scott Wood Subject: [U-Boot] [PATCH 17/22] mtd: nand: allow drivers to request minimum alignment for passed buffer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In some cases, nand_do_{read,write}_ops is passed with unaligned ops->datbuf. Drivers using DMA will be unhappy about unaligned buffer. The new struct member, buf_align, represents the minimum alignment the driver require for the buffer. If the buffer passed from the upper MTD layer does not have enough alignment, nand_do_*_ops will use bufpoi. Signed-off-by: Masahiro Yamada Signed-off-by: Boris Brezillon [Linux commit: 477544c62a84d3bacd9f90ba75ffc16c04d78071] --- drivers/mtd/nand/nand_base.c | 8 ++++++++ include/linux/mtd/nand.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 16d4554..f3c515b 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1720,6 +1720,9 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, if (!aligned) use_bufpoi = 1; + else if (chip->options & NAND_USE_BOUNCE_BUFFER) + use_bufpoi = !IS_ALIGNED((unsigned long)buf, + chip->buf_align); else use_bufpoi = 0; @@ -2575,6 +2578,9 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, if (part_pagewr) use_bufpoi = 1; + else if (chip->options & NAND_USE_BOUNCE_BUFFER) + use_bufpoi = !IS_ALIGNED((unsigned long)buf, + chip->buf_align); else use_bufpoi = 0; @@ -3119,6 +3125,8 @@ static void nand_set_defaults(struct nand_chip *chip, int busw) init_waitqueue_head(&chip->controller->wq); } + if (!chip->buf_align) + chip->buf_align = 1; } /* Sanitize ONFI strings so we can safely print them */ diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index be30059..90c6010 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -752,6 +752,7 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) * 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 * @scan_bbt: [REPLACEABLE] function to scan bad block table @@ -893,6 +894,7 @@ struct nand_chip { struct nand_ecc_ctrl ecc; struct nand_buffers *buffers; + unsigned long buf_align; struct nand_hw_control hwcontrol; uint8_t *bbt;