[PATCH v2] mtd: nand: Add support to use nand_base poi databuf as bounce buffer

Kamal Dasu kdasu.kdev at gmail.com
Fri Apr 25 09:10:43 PDT 2014


Huang,

"In the gpmi driver, i do a memcpy for the highmem buffer passed from
upper layer."

In other l2-mtd driver examples when the mapping fails those drivers
are reverting to bouce buffering using kmall'd dma buffer and memcpy
to highmem buffer. So the solutions have been implemented in the
l2-mtd (lowest level nand controller) driver.

In contrast this in change in nand_base uses the generic mm api
virt_addr_valid() to check if the passed address is in highmem, and if
it is I am not trying to convert(map) it, rather using the kmalloc'd
databuf in nand_base and memcpy to/from the highmem buffer. Also
using this check is optional, if l2-mtd driver can handle highmem in
other ways like gpmi, then chip->option need not be set.

"Which dma api do you use?"

For mapping the va to pa dma_map_single() is used.

"In the ARM platform, we use the sg_init_one to initialize the sg.
It can only convert the kmalloc memory, please see the code:
   #define __virt_to_phys(x)    ((x) - PAGE_OFFSET + PHYS_OFFSET)
It does a linear convert for a kernel address.
So in the ARM platform, it can _NOT_ support the highmem which is not linear."

I am not converting the address anywhere, merely checking if it is in highmem.
Are you suggesting that using virt_addr_valid() for ARM platform is
not sufficient ?.
I see that ret= dma_map_sg() is being used in case of the gpmi driver
to achieve the same.

Thanks
Kamal

On Fri, Apr 25, 2014 at 3:59 AM, Huang Shijie <b32955 at freescale.com> wrote:
> On Fri, Apr 25, 2014 at 03:43:13PM +0800, Huang Shijie wrote:
>> On Thu, Apr 24, 2014 at 11:52:41PM -0400, Kamal Dasu wrote:
>> > Huang,
>> >
>> > "could you show us how do the driver use the highmem buffer?"
>> >
>> > This is the stack on a BMIPS platform we are doing a read dma transaction.
>> > drv_*  calls are from out of tree nand controller  driver. This
>> I can read the driver since it is not in the l2-mtd. :(
>
> s/can/can't/
>
>>
>> > example shows the driver trying to map
>> > highmem virtual address(0xfe1141e0)  for DMA operation passed from
>>
>> Which dma api do you use?
>
> In the ARM platform, we use the sg_init_one to initialize the sg.
>
> It can only convert the kmalloc memory, please see the code:
>
>    #define __virt_to_phys(x)    ((x) - PAGE_OFFSET + PHYS_OFFSET)
>
> It does a linear convert for a kernel address.
> So in the ARM platform, it can _NOT_ support the highmem which is not linear.
>
>
> I am not familiar with MIPS.
>
> I do not know how the MIPS convert the highmem address.
>
> thanks
> Huang Shijie



More information about the linux-mtd mailing list