[RFC PATCH v7 12/13] dma-buf: system_heap: Allocate shared buffers using CoCo shared memory allocator

Christian König christian.koenig at amd.com
Wed Sep 23 01:46:34 PDT 2026


On 9/23/26 10:32, Aneesh Kumar K.V wrote:
> Catalin Marinas <catalin.marinas at arm.com> writes:
> 
>> On Mon, Sep 21, 2026 at 08:18:46PM +0530, Aneesh Kumar K.V (Arm) wrote:
>>> @@ -405,6 +396,7 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
>>>  {
>>>  	struct system_heap_buffer *buffer;
>>>  	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
>>> +	struct cc_shared_layout layout;
>>>  	unsigned long size_remaining = len;
>>>  	unsigned long sg_remaining = len;
>>>  	unsigned int max_order = orders[0];
>>> @@ -417,6 +409,14 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
>>>  	struct page *page, *tmp_page;
>>>  	int i, ret = -ENOMEM;
>>>  
>>> +	if (cc_shared) {
>>> +		ret = cc_shared_calc_layout(len, &layout);
>>
>> You should not override 'ret' here, it was set to -ENOMEM for a reason.
>> cc_shared_calc_layout() succeeds resetting 'ret' and some further down
>> allocation failure, goto free will return ERR_PTR(0).
> 
> 
> Agreed. I’ll fix this in the next revision.

Please CC me on that as well, I will try to find time to take a look.

Regards,
Christian.

> 
> -aneesh




More information about the linux-arm-kernel mailing list