From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
linux-input@vger.kernel.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [RFC PATCH v4 3/6] i2c: add docs to clarify DMA handling
Date: Sat, 9 Sep 2017 16:34:51 -0300 [thread overview]
Message-ID: <20170909163407.2f49b19d@vento.lan> (raw)
In-Reply-To: <20170909152705.tmnenengi4aqy3tc@ninjato>
Em Sat, 9 Sep 2017 17:27:06 +0200
Wolfram Sang <wsa@the-dreams.de> escreveu:
> > Yes, but the statistics that 10% of I2C bus master drivers
> > are DMA-safe is not true, if you take those into account ;-)
> >
> > Perhaps you could write it as (or something similar):
> >
> > At this time of writing, only +10% of I2C bus master
> > drivers for non-remote boards have DMA support implemented.
>
> No, this is confusing IMO. Being remote has nothing to with DMA. What
> has to do with DMA is that these are using USB as communication channel.
> And USB clearly needs DMA-safe buffers. The encapsulation needs DMA-safe
> buffers. So, I think the new sentence "other subsystems might impose"
> mentions that.
>
> Let me recap what this series is for:
>
> a) It makes clear that I2C subsystem does not require DMA-safety because
> for the reasons given in the textfile.
>
> If I2C is encapsulated over USB, then DMA-safety is of course required,
> but this comes from USB. So, those USB-I2C master drivers need to do
> something to make sure DMA-safety is guaranteed because i2c_msg buffers
> don't need to be DMA safe because of a). They could use the newly
> introduced features, but they don't have to.
>
> b) a flag for DMA safe i2c_msgs is added
>
> So, for messages we know to be DMA safe, we can flag that. Drivers
> could check that and use a bounce buffer if the flag is not set.
> However, this is all optional. Your drivers can still choose to not
> check the flag and everything will stay as before. Check patch 5 for a
> use case.
>
> c) helper functions for bounce buffers are added
>
> These are *helper* functions for drivers wishing to do DMA. A super
> simple bounce buffer support. Check patch 4 for a use case. Again, this
> is optional. Drivers can implement their own bounce buffer support. Or,
> as in your case, if you know that your buffers are good, then don't use
> any of this and things will keep going.
>
>
> This all is to allow bus master drivers to opt-in for DMA safety if they
> want to do DMA directly. Because currently, with a lot of i2c_msgs on
> stack, this is more or less working accidently.
>
> And, yes, I know I have to add this new flag to a few central places in
> client drivers. Otherwise, master drivers checking for DMA safety will
> initially have a performance regression. This is scheduled for V5 and
> mentioned in this series.
>
> > In the past, on lots of drivers, the i2c_xfer logic just used to assume
> > that the I2C client driver allocated a DMA-safe buffer, as it just used to
> > pass whatever buffer it receives directly to USB core. We did an effort to
> > change it, as it can be messy, but I'm not sure if this is solved everywhere.
>
> Good, I can imagine this being some effort. But again, this is because
> USB needs the DMA-safety, not I2C. AFAICS, most i2c_msgs are register
> accesses and thus, small messages.
>
> > The usage of I2C at the media subsystem predates the I2C subsystem.
> > at V4L2 drivers, a great effort was done to port it to fully use the
> > I2C subsystem when it was added upstream, but there were some problems
> > a the initial implementation of the i2c subsystem that prevented its
> > usage for the DVB drivers. By the time such restrictions got removed,
> > it was too late, as there were already a large amount of drivers relying
> > on i2c "low level" functions.
>
> Didn't know that, but this is good to know! Thanks.
>
> > Even on the drivers that use i2c_add_adapter(), the usage of DMA can't
> > be get by the above grep, as the DMA usage is actually at drivers/usb.
>
> Ok. But as said before, what works now will continue to work.
OK, good!
> This series is about clarifying that i2c_msg buffers need not to be DMA safe
> and offering some helpers for those bus master drivers wanting to opt-in
> to be sure.
>
> Clearer now?
Yeah, it is clearer for me. Thanks!
Anyway, it doesn't hurt if you could improve the documentation patch to
mention the above somewhow, as I want to avoid patches trying to make
existing media USB drivers to use the new flag without changing the
already existing DMA-safe logic there (causing double-buffering), or,
even worse, making the I2C bus DMA-unsafe because someone misread
this document.
Regards,
Mauro
next prev parent reply other threads:[~2017-09-09 19:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 14:14 [RFC PATCH v4 0/6] i2c: document DMA handling and add helpers for it Wolfram Sang
2017-08-17 14:14 ` Wolfram Sang
2017-08-17 14:14 ` [RFC PATCH v4 1/6] i2c: add a message flag for DMA safe buffers Wolfram Sang
2017-08-17 14:14 ` [RFC PATCH v4 2/6] i2c: add helpers to ease DMA handling Wolfram Sang
2017-08-17 14:14 ` [RFC PATCH v4 3/6] i2c: add docs to clarify " Wolfram Sang
2017-08-27 11:37 ` Mauro Carvalho Chehab
2017-09-08 8:56 ` Wolfram Sang
2017-09-08 8:56 ` Wolfram Sang
2017-09-08 11:08 ` Mauro Carvalho Chehab
2017-09-09 15:27 ` Wolfram Sang
2017-09-09 19:34 ` Mauro Carvalho Chehab [this message]
2017-09-20 17:18 ` Wolfram Sang
2017-09-20 17:18 ` Wolfram Sang
2017-09-20 18:22 ` Mauro Carvalho Chehab
2017-09-20 18:45 ` Wolfram Sang
2017-09-20 18:45 ` Wolfram Sang
2017-08-17 14:14 ` [RFC PATCH v4 4/6] i2c: sh_mobile: use helper to decide if DMA is useful Wolfram Sang
2017-08-17 14:14 ` [RFC PATCH v4 5/6] i2c: rcar: skip DMA if buffer is not safe Wolfram Sang
2017-08-17 14:14 ` [RFC PATCH v4 6/6] i2c: dev: mark RDWR buffers as DMA_SAFE Wolfram Sang
2017-08-20 10:14 ` [RFC PATCH v4 0/6] i2c: document DMA handling and add helpers for it 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=20170909163407.2f49b19d@vento.lan \
--to=mchehab@s-opensource.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
--cc=wsa@the-dreams.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.