All of lore.kernel.org
 help / color / mirror / Atom feed
* vc4_bo_create: Failed to allocate from CMA
@ 2021-06-12 15:17 Stefan Wahren
  2021-06-17  9:36 ` nicolas saenz julienne
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Wahren @ 2021-06-12 15:17 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne; +Cc: DRI Development

Hi,

while testing the mainline kernel (arm64, defconfig) on Raspberry Pi 3 B
Plus with Raspberry Pi OS - 64 bit, sometimes X doesn't start into
desktop properly (unexpected and unusable login screen instead of auto
login or mouse pointer is show shorty and than switch back to black
screen in a loop). In that case dmesg shows the following:

[   74.737106] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
CMA:
[   74.737558] vc4-drm soc:gpu: [drm]                            V3D: 
28976kb BOs (10)
[   74.737602] vc4-drm soc:gpu: [drm]                     V3D
shader:     44kb BOs (11)
[   74.737632] vc4-drm soc:gpu: [drm]                           dumb:  
4564kb BOs (5)
[   74.737664] vc4-drm soc:gpu: [drm]                         binner: 
16384kb BOs (1)
[   74.737697] vc4-drm soc:gpu: [drm]                total purged
BO:      4kb BOs (1)
[   74.739039] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
CMA:
[   74.739466] vc4-drm soc:gpu: [drm]                            V3D: 
28972kb BOs (9)
[   74.739512] vc4-drm soc:gpu: [drm]                     V3D
shader:     44kb BOs (11)
[   74.739541] vc4-drm soc:gpu: [drm]                           dumb:  
4564kb BOs (5)
[   74.739570] vc4-drm soc:gpu: [drm]                         binner: 
16384kb BOs (1)
[   74.739602] vc4-drm soc:gpu: [drm]                total purged
BO:      4kb BOs (1)
[   74.740718] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
CMA:
[   74.741138] vc4-drm soc:gpu: [drm]                            V3D: 
28972kb BOs (9)
[   74.741171] vc4-drm soc:gpu: [drm]                     V3D
shader:     44kb BOs (11)
[   74.741202] vc4-drm soc:gpu: [drm]                           dumb:  
4564kb BOs (5)
[   74.741231] vc4-drm soc:gpu: [drm]                         binner: 
16384kb BOs (1)
[   74.741263] vc4-drm soc:gpu: [drm]                total purged
BO:      4kb BOs (1)
...

I have only seen this issue on arm64 with latest mainline kernel
(5.13.0-rc5-00130-gf21b807c3cf8), but also with older kernel versions.
So it's not a regression. It seems 64 bit needs more CMA.

In case X started properly i was also able to reproduce these errors
above by dis- and reconneting HDMI.

So i increased CMA in bcm283x.dtsi and the problem disappeared:

iff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index b83a864..d1304cb 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -37,7 +37,7 @@
 
         cma: linux,cma {
             compatible = "shared-dma-pool";
-            size = <0x4000000>; /* 64MB */
+            size = <0x6000000>; /* 96MB */
             reusable;
             linux,cma-default;
         };

The questions are:

Is this the right way (tm) to fix this problem?

And what is a sensible value (don't have a 4K display to test)?

Best regards
Stefan


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: vc4_bo_create: Failed to allocate from CMA
  2021-06-12 15:17 vc4_bo_create: Failed to allocate from CMA Stefan Wahren
@ 2021-06-17  9:36 ` nicolas saenz julienne
  2021-06-17 10:27   ` Daniel Stone
  2021-06-17 17:54   ` Stefan Wahren
  0 siblings, 2 replies; 4+ messages in thread
From: nicolas saenz julienne @ 2021-06-17  9:36 UTC (permalink / raw)
  To: Stefan Wahren, Maxime Ripard; +Cc: DRI Development

On Sat, 2021-06-12 at 17:17 +0200, Stefan Wahren wrote:
> Hi,
> 
> while testing the mainline kernel (arm64, defconfig) on Raspberry Pi 3 B
> Plus with Raspberry Pi OS - 64 bit, sometimes X doesn't start into
> desktop properly (unexpected and unusable login screen instead of auto
> login or mouse pointer is show shorty and than switch back to black
> screen in a loop). In that case dmesg shows the following:
> 
> [   74.737106] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
> CMA:
> [   74.737558] vc4-drm soc:gpu: [drm]                            V3D: 
> 28976kb BOs (10)
> [   74.737602] vc4-drm soc:gpu: [drm]                     V3D
> shader:     44kb BOs (11)
> [   74.737632] vc4-drm soc:gpu: [drm]                           dumb:  
> 4564kb BOs (5)
> [   74.737664] vc4-drm soc:gpu: [drm]                         binner: 
> 16384kb BOs (1)
> [   74.737697] vc4-drm soc:gpu: [drm]                total purged
> BO:      4kb BOs (1)
> [   74.739039] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
> CMA:
> [   74.739466] vc4-drm soc:gpu: [drm]                            V3D: 
> 28972kb BOs (9)
> [   74.739512] vc4-drm soc:gpu: [drm]                     V3D
> shader:     44kb BOs (11)
> [   74.739541] vc4-drm soc:gpu: [drm]                           dumb:  
> 4564kb BOs (5)
> [   74.739570] vc4-drm soc:gpu: [drm]                         binner: 
> 16384kb BOs (1)
> [   74.739602] vc4-drm soc:gpu: [drm]                total purged
> BO:      4kb BOs (1)
> [   74.740718] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
> CMA:
> [   74.741138] vc4-drm soc:gpu: [drm]                            V3D: 
> 28972kb BOs (9)
> [   74.741171] vc4-drm soc:gpu: [drm]                     V3D
> shader:     44kb BOs (11)
> [   74.741202] vc4-drm soc:gpu: [drm]                           dumb:  
> 4564kb BOs (5)
> [   74.741231] vc4-drm soc:gpu: [drm]                         binner: 
> 16384kb BOs (1)
> [   74.741263] vc4-drm soc:gpu: [drm]                total purged
> BO:      4kb BOs (1)
> ...
> 
> I have only seen this issue on arm64 with latest mainline kernel
> (5.13.0-rc5-00130-gf21b807c3cf8), but also with older kernel versions.
> So it's not a regression. It seems 64 bit needs more CMA.
> 
> In case X started properly i was also able to reproduce these errors
> above by dis- and reconneting HDMI.
> 
> So i increased CMA in bcm283x.dtsi and the problem disappeared:
> 
> iff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
> index b83a864..d1304cb 100644
> --- a/arch/arm/boot/dts/bcm283x.dtsi
> +++ b/arch/arm/boot/dts/bcm283x.dtsi
> @@ -37,7 +37,7 @@
>  
>          cma: linux,cma {
>              compatible = "shared-dma-pool";
> -            size = <0x4000000>; /* 64MB */
> +            size = <0x6000000>; /* 96MB */
>              reusable;
>              linux,cma-default;
>          };
> 
> The questions are:
> 
> Is this the right way (tm) to fix this problem?

Frankly I don't know if there is a better way. IIRC opensuse and downstream use
DT overlays to cater for this limitation. It seems reasonable to bump the
value. But it'll be in detriment of users that don't care much for graphical
interfaces. Nonetheless, I'm not familiar with how DRM handles CMA/DMA memory.
So let me have a look at it. Maybe there is a SW fix. At first glance I'm
surprised they can't defer to normal page allocations when CMA isn't capable of
honoring the request (like the dma code does).

> And what is a sensible value (don't have a 4K display to test)?

The default for downstream is 256MB. But I've read discussions in the forum
where people needed even more. IIUC it's use-case dependent, resolution is only
one variable, you might then try to run a game and run out of memory there.

Regards,
Nicolas


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: vc4_bo_create: Failed to allocate from CMA
  2021-06-17  9:36 ` nicolas saenz julienne
@ 2021-06-17 10:27   ` Daniel Stone
  2021-06-17 17:54   ` Stefan Wahren
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Stone @ 2021-06-17 10:27 UTC (permalink / raw)
  To: nicolas saenz julienne; +Cc: Stefan Wahren, Maxime Ripard, DRI Development

On Thu, 17 Jun 2021 at 10:36, nicolas saenz julienne <nsaenz@kernel.org> wrote:
> Frankly I don't know if there is a better way. IIRC opensuse and downstream use
> DT overlays to cater for this limitation. It seems reasonable to bump the
> value. But it'll be in detriment of users that don't care much for graphical
> interfaces. Nonetheless, I'm not familiar with how DRM handles CMA/DMA memory.
> So let me have a look at it. Maybe there is a SW fix. At first glance I'm
> surprised they can't defer to normal page allocations when CMA isn't capable of
> honoring the request (like the dma code does).

DMA transfers can be split into multiple transactions at the cost of
being a bit slower. But there isn't a fallback for graphics buffers;
you can't display a quarter of a screen at a time. If the hardware did
support buffers being backed by multiple discontiguous pages, then it
wouldn't need CMA in the first place ...

Cheers,
Daniel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: vc4_bo_create: Failed to allocate from CMA
  2021-06-17  9:36 ` nicolas saenz julienne
  2021-06-17 10:27   ` Daniel Stone
@ 2021-06-17 17:54   ` Stefan Wahren
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Wahren @ 2021-06-17 17:54 UTC (permalink / raw)
  To: nicolas saenz julienne, Maxime Ripard; +Cc: DRI Development

Hi Nicolas,

Am 17.06.21 um 11:36 schrieb nicolas saenz julienne:
> On Sat, 2021-06-12 at 17:17 +0200, Stefan Wahren wrote:
>> Hi,
>>
>> while testing the mainline kernel (arm64, defconfig) on Raspberry Pi 3 B
>> Plus with Raspberry Pi OS - 64 bit, sometimes X doesn't start into
>> desktop properly (unexpected and unusable login screen instead of auto
>> login or mouse pointer is show shorty and than switch back to black
>> screen in a loop). In that case dmesg shows the following:
>>
>> [   74.737106] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
>> CMA:
>> [   74.737558] vc4-drm soc:gpu: [drm]                            V3D: 
>> 28976kb BOs (10)
>> [   74.737602] vc4-drm soc:gpu: [drm]                     V3D
>> shader:     44kb BOs (11)
>> [   74.737632] vc4-drm soc:gpu: [drm]                           dumb:  
>> 4564kb BOs (5)
>> [   74.737664] vc4-drm soc:gpu: [drm]                         binner: 
>> 16384kb BOs (1)
>> [   74.737697] vc4-drm soc:gpu: [drm]                total purged
>> BO:      4kb BOs (1)
>> [   74.739039] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
>> CMA:
>> [   74.739466] vc4-drm soc:gpu: [drm]                            V3D: 
>> 28972kb BOs (9)
>> [   74.739512] vc4-drm soc:gpu: [drm]                     V3D
>> shader:     44kb BOs (11)
>> [   74.739541] vc4-drm soc:gpu: [drm]                           dumb:  
>> 4564kb BOs (5)
>> [   74.739570] vc4-drm soc:gpu: [drm]                         binner: 
>> 16384kb BOs (1)
>> [   74.739602] vc4-drm soc:gpu: [drm]                total purged
>> BO:      4kb BOs (1)
>> [   74.740718] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from
>> CMA:
>> [   74.741138] vc4-drm soc:gpu: [drm]                            V3D: 
>> 28972kb BOs (9)
>> [   74.741171] vc4-drm soc:gpu: [drm]                     V3D
>> shader:     44kb BOs (11)
>> [   74.741202] vc4-drm soc:gpu: [drm]                           dumb:  
>> 4564kb BOs (5)
>> [   74.741231] vc4-drm soc:gpu: [drm]                         binner: 
>> 16384kb BOs (1)
>> [   74.741263] vc4-drm soc:gpu: [drm]                total purged
>> BO:      4kb BOs (1)
>> ...
>>
>> I have only seen this issue on arm64 with latest mainline kernel
>> (5.13.0-rc5-00130-gf21b807c3cf8), but also with older kernel versions.
>> So it's not a regression. It seems 64 bit needs more CMA.
>>
>> In case X started properly i was also able to reproduce these errors
>> above by dis- and reconneting HDMI.
>>
>> So i increased CMA in bcm283x.dtsi and the problem disappeared:
>>
>> iff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
>> index b83a864..d1304cb 100644
>> --- a/arch/arm/boot/dts/bcm283x.dtsi
>> +++ b/arch/arm/boot/dts/bcm283x.dtsi
>> @@ -37,7 +37,7 @@
>>  
>>          cma: linux,cma {
>>              compatible = "shared-dma-pool";
>> -            size = <0x4000000>; /* 64MB */
>> +            size = <0x6000000>; /* 96MB */
>>              reusable;
>>              linux,cma-default;
>>          };
>>
>> The questions are:
>>
>> Is this the right way (tm) to fix this problem?
> Frankly I don't know if there is a better way. IIRC opensuse and downstream use
> DT overlays to cater for this limitation. It seems reasonable to bump the
> value. But it'll be in detriment of users that don't care much for graphical
> interfaces. Nonetheless, I'm not familiar with how DRM handles CMA/DMA memory.
> So let me have a look at it. Maybe there is a SW fix. At first glance I'm
> surprised they can't defer to normal page allocations when CMA isn't capable of
> honoring the request (like the dma code does).

a compromise might be to increase the CMA size based on the SoC type
(newer generations have more memory)

BCM2835 => 64 MB
BCM2836, BCM2837 => 256 MB

>
>> And what is a sensible value (don't have a 4K display to test)?
> The default for downstream is 256MB. But I've read discussions in the forum
> where people needed even more. IIUC it's use-case dependent, resolution is only
> one variable, you might then try to run a game and run out of memory there.

Sure this wasn't intend to make everybody happy. But i would expect to
start X reliable at least.

Regards
Stefan

>
> Regards,
> Nicolas
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-17 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-12 15:17 vc4_bo_create: Failed to allocate from CMA Stefan Wahren
2021-06-17  9:36 ` nicolas saenz julienne
2021-06-17 10:27   ` Daniel Stone
2021-06-17 17:54   ` Stefan Wahren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.