Re: [PATCH] misc: sram: Add dma-heap-export reserved SRAM area type

From: Andrew F. Davis
Date: Wed Apr 29 2020 - 15:05:58 EST


On 4/27/20 11:17 AM, Rob Herring wrote:
> On Fri, Apr 24, 2020 at 5:27 PM Andrew F. Davis <afd@xxxxxx> wrote:
>>
>> This new export type exposes to userspace the SRAM area as a DMA-Heap,
>> this allows for allocations as DMA-BUFs that can be consumed by various
>> DMA-BUF supporting devices.
>>
>> Signed-off-by: Andrew F. Davis <afd@xxxxxx>
>> ---
>> .../devicetree/bindings/sram/sram.yaml | 8 +
>
> Separate patch and needs to go to DT list...
>


Okay, will split for v2.


>> drivers/misc/Kconfig | 7 +
>> drivers/misc/Makefile | 1 +
>> drivers/misc/sram-dma-heap.c | 243 ++++++++++++++++++
>> drivers/misc/sram.c | 20 +-
>> drivers/misc/sram.h | 17 ++
>> 6 files changed, 292 insertions(+), 4 deletions(-)
>> create mode 100644 drivers/misc/sram-dma-heap.c
>>
>> diff --git a/Documentation/devicetree/bindings/sram/sram.yaml b/Documentation/devicetree/bindings/sram/sram.yaml
>> index 7b83cc6c9bfa..b8e33c8d205d 100644
>> --- a/Documentation/devicetree/bindings/sram/sram.yaml
>> +++ b/Documentation/devicetree/bindings/sram/sram.yaml
>> @@ -105,6 +105,14 @@ patternProperties:
>> manipulation of the page attributes.
>> type: boolean
>>
>> + dma-heap-export:
>> + description:
>> + Similar to 'pool' and 'export' this region will be exported for use
>> + by drivers, devices, and userspace using the DMA-Heaps framework.
>> + NOTE: This region must be page aligned on start and end in order to
>> + properly allow manipulation of the page attributes.
>> + type: boolean
>
> Though I'm not sure this should be in DT. You have to change your
> firmware to enable a new kernel feature? We also already have 'export'
> which sounds like the same function. Or 'pool' though reading the
> description, I don't really understand it's use.
>


Maybe I could just re-use 'export', right now that property causes the
SRAM region to be exported to userspace as a file one can read/write.
Exporting via dma-heaps/dma-buf allows more flexibility as one can pass
the exported regions to other devices or mmap them directly in userspace.

It's up to the SRAM driver maintainer if re-purposing that property in
the driver is acceptable.

'Pool' doesn't make much sense to me either, it creates a gen-pool out
of the region, but I cant find any users not in combination with the
other properties.


> What combination of all 3 of these options would be valid?
>


>From looking at the SRAM driver, it seems each of the option must be
used exclusively per region, combining will cause issues. I can update
the documentation for the same after we settle on a strategy for this
new property.

Andrew


> Rob
>