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


Groups > linux.kernel > #1618258

Re: [PATCH] of: change fixup of dma-ranges size to error

From Frank Rowand <frowand.list@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] of: change fixup of dma-ranges size to error
Date 2017-04-06 20:40 +0200
Message-ID <ttku5-4wp-1@gated-at.bofh.it> (permalink)
References <tt95E-4Qc-5@gated-at.bofh.it> <ttggO-16l-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 04/06/17 07:03, Rob Herring wrote:
> On Thu, Apr 6, 2017 at 1:18 AM,  <frowand.list@gmail.com> wrote:
>> From: Frank Rowand <frank.rowand@sony.com>
>>
>> of_dma_get_range() has workaround code to fixup a device tree that
>> incorrectly specified a mask instead of a size for property
>> dma-ranges.  That device tree was fixed a year ago in v4.6, so
>> the workaround is no longer needed.  Leave a data validation
>> check in place, but no longer do the fixup.  Move the check
>> one level deeper in the call stack so that other possible users
>> of dma-ranges will also be protected.
>>
>> The fix to the device tree was in
>> commit c91cb9123cdd ("dtb: amd: Fix DMA ranges in device tree").
> 
> NACK.
> This was by design. You can't represent a size of 2^64 or 2^32.

I agree that being unable to represent a size of 2^32 in a u32 and
a size of 2^64 in a u64 is the underlying issue.

But the code to convert a mask to a size is _not_ design, it is a
hack that temporarily worked around a device tree that did not follow
the dma-ranges binding in the ePAPR.

That device tree was corrected a year ago to provide a size instead of
a mask.

> Well, technically you can for the latter, but then you have to grow
> #size-cells to 2 for an otherwise all 32-bit system which seems kind
> of pointless and wasteful. You could further restrict this to only
> allow ~0 and not just any case with bit 0 set.
> 
> I'm pretty sure AMD is not the only system. There were 32-bit systems too.

I examined all instances of property dma-ranges in in tree dts files in
Linux 4.11-rc1.  There are none that incorrectly specify mask instead of
size.

#size-cells only changes to 2 for the dma-ranges property and the ranges
property when size is 2^32, so that is a very small amount of space.

The patch does not allow for a size of 2^64.  If a system requires a
size of 2^64 then the type of size needs to increase to be larger
than a u64.  If you would like for the code to be defensive and
detect a device tree providing a size of 2^64 then I can add a
check to of_dma_get_range() to return -EINVAL if #size-cells > 2.
When that error triggers, the type of size can be changed.

> 
> Rob
> 

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


Thread

[PATCH] of: change fixup of dma-ranges size to error frowand.list@gmail.com - 2017-04-06 08:30 +0200
  Re: [PATCH] of: change fixup of dma-ranges size to error Rob Herring <robh+dt@kernel.org> - 2017-04-06 16:10 +0200
    Re: [PATCH] of: change fixup of dma-ranges size to error Frank Rowand <frowand.list@gmail.com> - 2017-04-06 20:40 +0200
      Re: [PATCH] of: change fixup of dma-ranges size to error Rob Herring <robh+dt@kernel.org> - 2017-04-07 00:50 +0200
        Re: [PATCH] of: change fixup of dma-ranges size to error Frank Rowand <frowand.list@gmail.com> - 2017-04-07 07:20 +0200
          Re: [PATCH] of: change fixup of dma-ranges size to error Rob Herring <robh+dt@kernel.org> - 2017-04-07 19:20 +0200
            Re: [PATCH] of: change fixup of dma-ranges size to error Frank Rowand <frowand.list@gmail.com> - 2017-04-08 01:30 +0200
              Re: [PATCH] of: change fixup of dma-ranges size to error Sricharan R <sricharan@codeaurora.org> - 2017-04-10 13:50 +0200
                Re: [PATCH] of: change fixup of dma-ranges size to error Frank Rowand <frowand.list@gmail.com> - 2017-04-10 14:00 +0200
            Re: [PATCH] of: change fixup of dma-ranges size to error Robin Murphy <robin.murphy@arm.com> - 2017-04-10 15:20 +0200

csiph-web