mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: Ben Dooks <ben-i2c@fluff.org>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	anish <anish198519851985@gmail.com>,
	gregkh@suse.de, manuel.stahl@iis.fraunhofer.de,
	lucas.demarchi@profusion.mobi, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	Linux I2C <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH] staging iio: Replace kmalloc with local variable
Date: Tue, 7 Jun 2011 16:02:06 +0200	[thread overview]
Message-ID: <20110607160206.6cb3168d@endymion.delvare> (raw)
In-Reply-To: <20110607134135.GD15795@trinity.fluff.org>

On Tue, 7 Jun 2011 14:41:35 +0100, Ben Dooks wrote:
> On Tue, Jun 07, 2011 at 02:00:23PM +0100, Jonathan Cameron wrote:
> > On 06/07/11 13:39, anish wrote:
> > > From: anish kumar <anish198519851985@gmail.com>
> > > 
> > > replaced kmalloc with local variable as I2C(in this case) doesn't require
> > > kmalloc memory it can do with stack memory.
> > I've cc'd linux-i2c just to check I'm right about the whole i2c doesn't need
> > dma safe buffers bit...
> 
> No, it is down to the i2c driver, and from recollection dma from stack is
> not recommended, due to things like cache line alignment. Please do not
> do this.

To be clearer, it is down to the i2c BUS (adapter) driver, NOT the i2c
device driver. So the patch is correct.

Keep in mind that not all I2C/SMBus controllers care about DMA. In fact,
most don't (at least in the set I am maintaining - might be different
an embedded.) So calling kmalloc for every transfer in every I2C device
driver "just in case" is very much counterproductive.

And, if a controller does DMA and needs well-aligned, dynamically
allocated buffer, its driver would hopefully allocate the buffer ONCE
and keep it around, rather than reallocating it for every transfer.

-- 
Jean Delvare

  parent reply	other threads:[~2011-06-07 14:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 12:39 anish
2011-06-07 13:00 ` Jonathan Cameron
2011-06-07 13:41   ` Ben Dooks
2011-06-07 13:54     ` Jonathan Cameron
2011-06-07 14:04       ` Hennerich, Michael
2011-06-07 14:02     ` Jean Delvare [this message]
     [not found]       ` <BANLkTim5-ZKXtDkSQyHAJ9-iKtOPsJ917A@mail.gmail.com>
     [not found]         ` <BANLkTi=e0A2G-d+t4VF5V0gj+eNoh3KRnQ@mail.gmail.com>
2011-06-09  8:29           ` Jean Delvare
     [not found]             ` <BANLkTimq_5rmB+UkaxZwrOtV-ZF3+fEOgQ@mail.gmail.com>
2011-06-09  8:48               ` Jonathan Cameron
2011-06-09 10:46                 ` Jonathan Cameron
     [not found]                   ` <BANLkTik4Tfd73iKcDsXK-sfy6_ADVX4oYA@mail.gmail.com>
2011-06-09 14:51                     ` Jonathan Cameron

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=20110607160206.6cb3168d@endymion.delvare \
    --to=khali@linux-fr.org \
    --cc=anish198519851985@gmail.com \
    --cc=ben-i2c@fluff.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=jic23@cam.ac.uk \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    --cc=manuel.stahl@iis.fraunhofer.de \
    /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

all inboxes | Powered by JetHome®