Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1381719

Re: [PATCH V2] net: ethernet: mellanox: correct page conversion

From Sinan Kaya <okaya@codeaurora.org>
Newsgroups linux.kernel
Subject Re: [PATCH V2] net: ethernet: mellanox: correct page conversion
Date 2016-04-18 15:50 +0200
Message-ID <rphIT-6ug-29@gated-at.bofh.it> (permalink)
References <roGT0-2e3-15@gated-at.bofh.it> <rpgjN-5u2-17@gated-at.bofh.it> <rph6b-69y-27@gated-at.bofh.it> <rphfR-6dw-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 4/18/2016 9:10 AM, Christoph Hellwig wrote:
> On Mon, Apr 18, 2016 at 09:06:18AM -0400, okaya@codeaurora.org wrote:
>> On 2016-04-18 08:12, Christoph Hellwig wrote:
>>> On Sat, Apr 16, 2016 at 06:23:32PM -0400, Sinan Kaya wrote:
>>>> Current code is assuming that the address returned by dma_alloc_coherent
>>>> is a logical address. This is not true on ARM/ARM64 systems.
>>>
>>> Can you explain what you mean with a 'logical address' and what actual
>>> issue you're trying to solve?
>>
Here is a good description of logical address vs. virtual address.

https://www.quora.com/What-is-the-Kernel-logical-and-virtual-addresses-What-is-the-difference-between-them-What-is-the-type-of-addresses-listed-in-the-System-map


>> Vmap call is failing on arm64 systems because dma alloc api already returns
>> an address mapped with vmap.
> 
> Please state your problem clearly.  What I'm reverse engineering from
> your posts is:  because dma_alloc_coherent uses vmap-like mappings on
> arm64 (all, some systems?) 

All arm64 systems. 

>a driver using a lot of them might run into
> limits of the vmap pool size.
> 
> Is this correct?
> 
No, the driver is plain broken without this patch. It causes a kernel panic 
during driver probe.

This is the definition of vmap API.

https://www.kernel.org/doc/htmldocs/kernel-api/API-vmap.html

VMAP allows you to make several pages look contiguous to the CPU. 
It can only be used against logical addresses returned from kmalloc 
or alloc_page. 

You cannot take several virtually mapped addresses returned by dma_alloc_coherent
and try to make them virtually contiguous again. 

The code happens to work on other architectures by pure luck. AFAIK, dma_alloc_coherent
returns logical addresses on Intel systems until it runs out of DMA memory. After 
that intel arch will also start returning virtually mapped addresses and this code
will also fail. ARM64 on the other hand always returns a virtually mapped address.

The goal of this code is to allocate a bunch of page sized memory and make it look
contiguous. It is just using the wrong API. The correct API is either kmalloc or
alloc_page map it with dma_map_page not dma_alloc_coherent.

The proper usage of dma_map_page requires code to call dma_sync API in correct
places to be compatible with noncoherent systems. This code is already assuming
coherency. It would be a nice to have dma_sync APIs in right places. There is no
harm in calling dma_sync API for coherent systems as they are no-ops in DMA mapping
layer whereas it is a cache flush for non-coherent systems.

>>
>> Please see arch/arm64/mm directory.
> ---end quoted text---
> 

I hope it is clear now. The previous email was the most I could type on my phone.

-- 
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-17 00:30 +0200
  Re: [PATCH V2] net: ethernet: mellanox: correct page conversion David Miller <davem@davemloft.net> - 2016-04-18 06:10 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion okaya@codeaurora.org - 2016-04-18 07:10 +0200
      Re: [PATCH V2] net: ethernet: mellanox: correct page conversion David Miller <davem@davemloft.net> - 2016-04-18 18:00 +0200
        Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-18 18:10 +0200
  Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Eli Cohen <eli@mellanox.com> - 2016-04-18 09:00 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-18 16:00 +0200
      Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Eli Cohen <eli@mellanox.com> - 2016-04-18 16:30 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-18 16:40 +0200
      RE: [PATCH V2] net: ethernet: mellanox: correct page conversion Eli Cohen <eli@mellanox.com> - 2016-04-18 17:00 +0200
        Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-18 17:20 +0200
          Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-18 17:30 +0200
            Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-18 17:50 +0200
              Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-18 19:50 +0200
              Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-19 10:00 +0200
  Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-18 14:20 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion okaya@codeaurora.org - 2016-04-18 15:10 +0200
      Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-18 15:20 +0200
        Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-18 15:50 +0200
          Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-18 16:00 +0200
          Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Timur Tabi <timur@codeaurora.org> - 2016-04-18 17:20 +0200
            Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-18 17:30 +0200
  Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Christoph Hellwig <hch@infradead.org> - 2016-04-19 20:30 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-19 20:40 +0200
      Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Eran Ben Elisha <eranlinuxmellanox@gmail.com> - 2016-04-20 13:10 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-20 15:40 +0200
      Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Timur Tabi <timur@codeaurora.org> - 2016-04-20 15:50 +0200
    Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-20 15:40 +0200
      Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Eran Ben Elisha <eranlinuxmellanox@gmail.com> - 2016-04-20 20:50 +0200
        Re: [PATCH V2] net: ethernet: mellanox: correct page conversion Sinan Kaya <okaya@codeaurora.org> - 2016-04-20 20:50 +0200

csiph-web