linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dedekind1@gmail.com (Artem Bityutskiy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/11] fsmc/nand: Provide contiguous buffers to dma
Date: Tue, 16 Oct 2012 10:11:51 +0300	[thread overview]
Message-ID: <1350371511.5769.43.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <CAN8TOE-7d=YUSYsHFw9X5vnz8cpSJYv5uZfvBpDyhg+-F_LDiQ@mail.gmail.com>

On Mon, 2012-10-15 at 09:27 -0700, Brian Norris wrote:
> > I'd really prefer to just switch to kmalloc() everywhere instead of
> > adding hacks like this to the drivers. Then if this is a problem for
> > someone, he can fix it by either switching to smaller buffers (possible
> > in many places), or by improving memory fragmentation issues on his
> > system, or by just using CMA.
> 
> I think I can suggest that this is already a problem on real systems.
> In bringing up a board on v3.3 kernel, I experienced a kernel memory
> allocation error when trying to memdup_user() in eraseblock-size
> regions. I believe I would experience more of these if all
> eraseblock-sized buffers were kmalloc()'d.
> 
> See the commit description for the following commit in mtd-utils.git:
> 
>     commit 71c76e74661492b4f68f670514866cfc85f47089
>     libmtd: fix mtd_write() issues for large data-only writes

Well, this is another work-around. The better way to fix this would be
to change kernel's 'mtdchar_write_ioctl()' to be iterative and avoid
calling 'memdup_user(len)' for arbitrary 'len' passed from user-space.

> I would prefer not building a solution that hopes kmalloc() can get a
> large contiguous buffer (remember, eraseblock sizes come as large as
> 2MB these days). A real solution like CMA or scatter-gather seems like
> a better idea.

Me too. But this does not happen. People bring this up for years. Of
course it is easier to hack drivers, and very understandable. So what
I would like to do is somehow force people to fix this issue.

So I thought about something like introducing an mtd_alloc() which
would:
   a. Try doing CMA allocation: dma_alloc_from_contiguous()
   b. If it fails, use kmalloc().

This function would probably need a cookie which it returns and which
the mtd_free() function would use to call either kfree() or
dma_release_from_contiguous()...

If both fail - bad luck. Go look at the code and switch to S-G lists
instead of allocating contiguous regions. As I said, in many places it
is easy to do, and there are few places when you would need to spend a
bit more time.

How does this sound to you?

-- 
Best Regards,
Artem Bityutskiy


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121016/04d3c8f5/attachment.sig>

  parent reply	other threads:[~2012-10-16  7:11 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 10:44 [PATCH 00/11] mtd/nand: fsmc driver updates Vipin Kumar
2012-10-09 10:44 ` [PATCH 01/11] fsmc/nand:FIX: Change the type for regs to void __iomem * Vipin Kumar
2012-10-09 17:14   ` viresh kumar
2012-10-10 16:49   ` Linus Walleij
2012-10-17 12:30   ` Artem Bityutskiy
2012-10-09 10:44 ` [PATCH 02/11] fsmc/nand: Rearrange the fsmc_nand_data structure and update comments Vipin Kumar
2012-10-09 11:52   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-11  4:24     ` Vipin Kumar
2012-10-09 17:15   ` viresh kumar
2012-10-09 10:44 ` [PATCH 03/11] fsmc/nand: Support multiple banks connected to controller Vipin Kumar
2012-10-09 11:55   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-10 10:28     ` Vipin Kumar
2012-10-17 12:31   ` Artem Bityutskiy
2012-10-09 10:44 ` [PATCH 04/11] fsmc/nand: Accept nand timing parameters via DT Vipin Kumar
2012-10-09 11:57   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-11  4:25     ` Vipin Kumar
2012-10-09 17:20   ` viresh kumar
2012-10-09 10:44 ` [PATCH 05/11] fsmc: Implement ready/busy through gpio pin Vipin Kumar
2012-10-09 11:59   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-09 17:34   ` viresh kumar
2012-10-09 10:44 ` [PATCH 06/11] fsmc/nand: Modify the wait to uninterruptible Vipin Kumar
2012-10-10 17:10   ` Linus Walleij
2012-10-17 12:47   ` Artem Bityutskiy
2012-10-09 10:44 ` [PATCH 07/11] fsmc/nand: Provide contiguous buffers to dma Vipin Kumar
2012-10-09 17:41   ` viresh kumar
2012-10-10 17:07   ` Linus Walleij
2012-10-11  3:16     ` viresh kumar
2012-10-11  4:07       ` Vipin Kumar
2012-10-11  4:08     ` Vipin Kumar
2012-10-11  4:15     ` viresh kumar
2012-10-11 16:06       ` Linus Walleij
2012-10-11 17:07         ` viresh kumar
2012-10-11 21:51           ` Linus Walleij
2012-10-12  3:55         ` Vipin Kumar
2012-10-15 13:18           ` Artem Bityutskiy
2012-10-15 16:27             ` Brian Norris
2012-10-15 19:51               ` Linus Walleij
2012-10-16  7:14                 ` Artem Bityutskiy
2012-10-16 10:05                   ` Linus Walleij
2012-10-21  7:38                     ` Brian Norris
2012-10-21 11:00                       ` Artem Bityutskiy
2012-10-21 12:02                         ` Artem Bityutskiy
2012-10-16  7:11               ` Artem Bityutskiy [this message]
2012-10-21  7:21                 ` Brian Norris
2012-10-09 10:44 ` [PATCH 08/11] fsmc/nand: Use relaxed variants of io accessors Vipin Kumar
2012-10-09 17:42   ` viresh kumar
2012-10-10 17:09   ` Linus Walleij
2012-10-09 10:44 ` [PATCH 09/11] fsmc/nand:FIX: replace change_bit routine Vipin Kumar
2012-10-10 17:22   ` Linus Walleij
2012-10-10 20:21     ` Nicolas Pitre
2012-10-11  4:17       ` Vipin Kumar
2012-10-10 20:45     ` Russell King - ARM Linux
2012-10-11  4:20       ` Vipin Kumar
2012-10-09 10:44 ` [PATCH 10/11] fsmc/nand: Add sw bch support for ecc calculation/correction Vipin Kumar
2012-10-09 11:50   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-10 10:33     ` Vipin Kumar
2012-10-09 10:44 ` [PATCH 11/11] nand: Increase the ecc placement locations to 640 Vipin Kumar
2012-10-17 12:47   ` Artem Bityutskiy
2012-10-18  6:36   ` Brian Norris
2012-10-17 12:48 ` [PATCH 00/11] mtd/nand: fsmc driver updates Artem Bityutskiy
2012-10-18  4:13   ` Vipin Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350371511.5769.43.camel@sauron.fi.intel.com \
    --to=dedekind1@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).