public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [i2c-mxs] Broken DMA operations from within a module
@ 2013-02-13 12:00 Enrico Scholz
       [not found] ` <lyehgkift9.fsf-ZECJmDZ6y6nH/BybaBJVFuwNITXz66n+UvKB7fB21xCELgA04lAiVw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Enrico Scholz @ 2013-02-13 12:00 UTC (permalink / raw)
  To: linux-i2c, linux-arm-kernel; +Cc: Wolfram Sang

Hi,

the i2c-mxs driver does not work when transmit buffers are located
within module memory.

E.g. when doing something like

	struct i2c_msg xfer = {
               .buf = "something",
               ...
        };

        ret = i2c_transfer(client->adapter, &xfer, 1);

random data will be sent because buf is not DMA mapable ("something" is
located in the .strtab section within module memory). MXS has a memory
layout like

    vmalloc : 0xc8800000 - 0xff000000   ( 872 MB)
    lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc04b1e8c   (4776 kB)
      .init : 0xc04b2000 - 0xc04e61ac   ( 209 kB)
      .data : 0xc04e8000 - 0xc051b578   ( 206 kB)
       .bss : 0xc051b578 - 0xc05eba44   ( 834 kB)

and is CONFIG_FLATMEM.  Buffers above are e.g. at 0xbf0cdaf0.

You can verify the problem e.g. with the edt-ft5x06.c touch driver;
dumping 'sg->dma_address' in mxs_dma_prep_slave_sg() shows physical
addresses like 0x3f0cdaf0 for such strings, which are outside of valid
memory (0x40000000-0x7fffffff).

Does the i2c layer require DMA mapable buffers in its xfer structures
(e.g. like usb), or is the problem in the generic ARM/MXS layer or in
the mxs i2c driver?



Enrico

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [i2c-mxs] Broken DMA operations from within a module
       [not found] ` <lyehgkift9.fsf-ZECJmDZ6y6nH/BybaBJVFuwNITXz66n+UvKB7fB21xCELgA04lAiVw@public.gmane.org>
@ 2013-02-13 12:14   ` Russell King - ARM Linux
       [not found]     ` <20130213121450.GA17833-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King - ARM Linux @ 2013-02-13 12:14 UTC (permalink / raw)
  To: Enrico Scholz
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Wolfram Sang

On Wed, Feb 13, 2013 at 01:00:50PM +0100, Enrico Scholz wrote:
> E.g. when doing something like
> 
> 	struct i2c_msg xfer = {
>                .buf = "something",
>                ...
>         };
> 
>         ret = i2c_transfer(client->adapter, &xfer, 1);
> 
> random data will be sent because buf is not DMA mapable ("something" is
> located in the .strtab section within module memory). MXS has a memory
> layout like

DMA buffers must be located in lowmem *always*.  This means placing them
in the .data segment does not work.  USB has been through this already
and it's well known there...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [i2c-mxs] Broken DMA operations from within a module
       [not found]     ` <20130213121450.GA17833-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
@ 2013-02-13 12:28       ` Enrico Scholz
  0 siblings, 0 replies; 3+ messages in thread
From: Enrico Scholz @ 2013-02-13 12:28 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Wolfram Sang

Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> writes:

>>                .buf = "something",
>> ...
>> random data will be sent because buf is not DMA mapable ("something" is
>> located in the .strtab section within module memory). MXS has a memory
>> layout like
>
> DMA buffers must be located in lowmem *always*.  This means placing them
> in the .data segment does not work.  USB has been through this already
> and it's well known there...

Yes; I know about USB and this requirement is explicitly mentioned in
the 'struct urb' documentation.  But I can not find something similar
for i2c_msg and lot of i2c drivers are working with non DMA mapable
buffers.


Enrico

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-13 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-13 12:00 [i2c-mxs] Broken DMA operations from within a module Enrico Scholz
     [not found] ` <lyehgkift9.fsf-ZECJmDZ6y6nH/BybaBJVFuwNITXz66n+UvKB7fB21xCELgA04lAiVw@public.gmane.org>
2013-02-13 12:14   ` Russell King - ARM Linux
     [not found]     ` <20130213121450.GA17833-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-02-13 12:28       ` Enrico Scholz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox