Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750859AbdCaEBL (ORCPT ); Fri, 31 Mar 2017 00:01:11 -0400 Received: from conssluserg-01.nifty.com ([210.131.2.80]:36343 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750727AbdCaEBJ (ORCPT ); Fri, 31 Mar 2017 00:01:09 -0400 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com v2V414vt006842 X-Nifty-SrcIP: [209.85.161.172] MIME-Version: 1.0 In-Reply-To: <1490861708-27813-4-git-send-email-yamada.masahiro@socionext.com> References: <1490861708-27813-1-git-send-email-yamada.masahiro@socionext.com> <1490861708-27813-4-git-send-email-yamada.masahiro@socionext.com> From: Masahiro Yamada Date: Fri, 31 Mar 2017 13:01:03 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 34/37] mtd: nand: allow drivers to request minimum alignment for passed buffer To: linux-mtd@lists.infradead.org Cc: Linux Kernel Mailing List , Boris Brezillon , David Woodhouse , Marek Vasut , Dinh Nguyen , Artem Bityutskiy , Graham Moore , Enrico Jorns , Chuanxiao Dong , Masami Hiramatsu , Jassi Brar , Masahiro Yamada Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1990 Lines: 66 Hi Boris, 2017-03-30 17:15 GMT+09:00 Masahiro Yamada : > 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 > --- > > I was hit by this problem when I ran > # mount -t jffs2 /dev/mtdblock* /mnt > > The buffer passed to nand_do_*_ops has 4 byte offset. > The Denali IP cannot do DMA to/from this buffer because it > requires 16 byte alignment for DMA. > > > Changes in v3: > - Newly added > > Changes in v2: None > > drivers/mtd/nand/nand_base.c | 12 ++++++++---- > include/linux/mtd/nand.h | 2 ++ > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > index e9d3195..b528ffa 100644 > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -1953,9 +1953,10 @@ 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 = !virt_addr_valid(buf); > - else > + else if (chip->options & NAND_USE_BOUNCE_BUFFER) { > + use_bufpoi = !virt_addr_valid(buf) || > + !IS_ALIGNED((unsigned long)buf, chip->buf_align); > + } else > use_bufpoi = 0; I noticed I added unneeded braces here by mistake. (When I was testing this part, I inserted printk here, then I forgot to remove the {} . ) Can you fix-up it? If requested, I can re-send it. -- Best Regards Masahiro Yamada