aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0636-ARM-dts-overlays-Unify-overlay-CMA-handling.patch
blob: 3c0f1e4388c875d198fec3ce4b88d228bec1f141 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
From de8fa25cdf3726c83ac0d7b3b1e28bcb6334aadd Mon Sep 17 00:00:00 2001
From: Eugen Hristev <eugen.hristev@microchip.com>
Date: Tue, 13 Apr 2021 12:57:01 +0200
Subject: [PATCH 159/247] media: atmel: atmel-isc: add checks for limiting
 frame sizes

When calling the subdev, certain subdev drivers will overwrite the
frame size and adding sizes which are beyond the ISC's capabilities.
Thus we need to ensure the frame size is cropped to the maximum caps.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/atmel/atmel-isc-base.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
index d987a8891bd9..02f1d1c6b06e 100644
--- a/drivers/media/platform/atmel/atmel-isc-base.c
+++ b/drivers/media/platform/atmel/atmel-isc-base.c
@@ -1338,6 +1338,12 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
 
 	v4l2_fill_pix_format(pixfmt, &format.format);
 
+	/* Limit to Atmel ISC hardware capabilities */
+	if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
+		pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
+	if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
+		pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
+
 	pixfmt->field = V4L2_FIELD_NONE;
 	pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
 	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
@@ -1373,6 +1379,12 @@ static int isc_set_fmt(struct isc_device *isc, struct v4l2_format *f)
 	if (ret < 0)
 		return ret;
 
+	/* Limit to Atmel ISC hardware capabilities */
+	if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
+		pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
+	if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
+		pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
+
 	isc->fmt = *f;
 
 	if (isc->try_config.sd_format && isc->config.sd_format &&
-- 
2.32.0
ef='#n293'>293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
From 3cd31a44e61e2219d730d6b1a4a13c8e15d6e395 Mon Sep 17 00:00:00 2001
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Date: Thu, 2 Apr 2020 19:54:33 +0200
Subject: [PATCH] ARM: dts: overlays: Unify overlay CMA handling

Now that we don't have to abuse the kernel command line to change CMA's
size we can clean-up and centralize CMA usage in overlays.

A new file, cma-overlay.dts is created to be used as a standalone
overlay or included on other overlays. All CMA users are converted to
this scheme. Ultimately upstream-overlay.dts is also updated to use the
default CMA size provided by upstream.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             | 19 +++++
 arch/arm/boot/dts/overlays/cma-overlay.dts    | 32 ++++++++
 .../boot/dts/overlays/upstream-overlay.dts    | 56 ++++---------
 .../dts/overlays/upstream-pi4-overlay.dts     | 66 +++++----------
 .../dts/overlays/vc4-fkms-v3d-overlay.dts     | 51 ++----------
 .../boot/dts/overlays/vc4-kms-v3d-overlay.dts | 66 ++++-----------
 .../dts/overlays/vc4-kms-v3d-pi4-overlay.dts  | 80 +++++--------------
 8 files changed, 129 insertions(+), 242 deletions(-)
 create mode 100644 arch/arm/boot/dts/overlays/cma-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -28,6 +28,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	audiosense-pi.dtbo \
 	audremap.dtbo \
 	balena-fin.dtbo \
+	cma.dtbo \
 	dht11.dtbo \
 	dionaudio-loco.dtbo \
 	dionaudio-loco-v2.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -554,6 +554,19 @@ Info:   This overlay is now deprecated -
 Load:   <Deprecated>
 
 
+Name:   cma
+Info:   Set custom CMA sizes, only use if you know what you are doing, might
+        clash with other overlays like vc4-fkms-v3d and vc4-kms-v3d.
+Load:   dtoverlay=cma,<param>=<val>
+Params: cma-256                 CMA is 256MB (needs 1GB)
+        cma-192                 CMA is 192MB (needs 1GB)
+        cma-128                 CMA is 128MB
+        cma-96                  CMA is 96MB
+        cma-64                  CMA is 64MB
+        cma-size                CMA size in bytes, 4MB aligned
+        cma-default             Use upstream's default value
+
+
 Name:   dht11
 Info:   Overlay for the DHT11/DHT21/DHT22 humidity/temperature sensors
         Also sometimes found with the part number(s) AM230x.
@@ -2675,6 +2688,8 @@ Params: cma-256                 CMA is 2
         cma-128                 CMA is 128MB
         cma-96                  CMA is 96MB
         cma-64                  CMA is 64MB
+        cma-size                CMA size in bytes, 4MB aligned
+        cma-default             Use upstream's default value
 
 
 Name:   vc4-kms-kippah-7inch
@@ -2692,6 +2707,8 @@ Params: cma-256                 CMA is 2
         cma-128                 CMA is 128MB
         cma-96                  CMA is 96MB
         cma-64                  CMA is 64MB
+        cma-size                CMA size in bytes, 4MB aligned
+        cma-default             Use upstream's default value
         audio                   Enable or disable audio over HDMI (default "on")
 
 
@@ -2703,6 +2720,8 @@ Params: cma-256                 CMA is 2
         cma-128                 CMA is 128MB
         cma-96                  CMA is 96MB
         cma-64                  CMA is 64MB
+        cma-size                CMA size in bytes, 4MB aligned
+        cma-default             Use upstream's default value
         audio                   Enable or disable audio over HDMI0 (default
                                 "on")
         audio1                  Enable or disable audio over HDMI1 (default
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/cma-overlay.dts
@@ -0,0 +1,32 @@
+/*
+ * cma.dts
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&cma>;
+		frag0: __overlay__ {
+			/*
+			 * The default size when using this overlay is 256 MB
+			 * and should be kept as is for backwards
+			 * compatibility.
+			 */
+			size = <0x10000000>;
+		};
+	};
+
+	__overrides__ {
+		cma-256 = <&frag0>,"size:0=",<0x10000000>;
+		cma-192 = <&frag0>,"size:0=",<0xC000000>;
+		cma-128 = <&frag0>,"size:0=",<0x8000000>;
+		cma-96  = <&frag0>,"size:0=",<0x6000000>;
+		cma-64  = <&frag0>,"size:0=",<0x4000000>;
+		cma-size = <&frag0>,"size:0"; /* in bytes, 4MB aligned */
+		cma-default = <0>,"-0";
+	};
+};
--- a/arch/arm/boot/dts/overlays/upstream-overlay.dts
+++ b/arch/arm/boot/dts/overlays/upstream-overlay.dts
@@ -1,4 +1,4 @@
-// redo: ovmerge -c vc4-kms-v3d-overlay.dts,cma-96 dwc2-overlay.dts,dr_mode=otg
+// redo: ovmerge -c vc4-kms-v3d-overlay.dts,cma-default dwc2-overlay.dts,dr_mode=otg
 
 /dts-v1/;
 /plugin/;
@@ -8,114 +8,90 @@
 / {
 	compatible = "brcm,bcm2835";
 	fragment@0 {
-		target-path = "/chosen";
+		target = <&cma>;
 		__dormant__ {
-			bootargs = "cma=256M";
+			size = <0x10000000>;
 		};
 	};
 	fragment@1 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=192M";
-		};
-	};
-	fragment@2 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=128M";
-		};
-	};
-	fragment@3 {
-		target-path = "/chosen";
-		__overlay__ {
-			bootargs = "cma=96M";
-		};
-	};
-	fragment@4 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=64M";
-		};
-	};
-	fragment@5 {
 		target = <&i2c2>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@6 {
+	fragment@2 {
 		target = <&fb>;
 		__overlay__ {
 			status = "disabled";
 		};
 	};
-	fragment@7 {
+	fragment@3 {
 		target = <&pixelvalve0>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@8 {
+	fragment@4 {
 		target = <&pixelvalve1>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@9 {
+	fragment@5 {
 		target = <&pixelvalve2>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@10 {
+	fragment@6 {
 		target = <&hvs>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@11 {
+	fragment@7 {
 		target = <&hdmi>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@12 {
+	fragment@8 {
 		target = <&v3d>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@13 {
+	fragment@9 {
 		target = <&vc4>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@14 {
+	fragment@10 {
 		target = <&clocks>;
 		__overlay__ {
 			claim-clocks = <BCM2835_PLLD_DSI0 BCM2835_PLLD_DSI1 BCM2835_PLLH_AUX BCM2835_PLLH_PIX>;
 		};
 	};
-	fragment@15 {
+	fragment@11 {
 		target = <&vec>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@16 {
+	fragment@12 {
 		target = <&txp>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@17 {
+	fragment@13 {
 		target = <&hdmi>;
 		__dormant__ {
 			dmas;
 		};
 	};
-	fragment@18 {
+	fragment@14 {
 		target = <&usb>;
 		#address-cells = <1>;
 		#size-cells = <1>;
--- a/arch/arm/boot/dts/overlays/upstream-pi4-overlay.dts
+++ b/arch/arm/boot/dts/overlays/upstream-pi4-overlay.dts
@@ -8,144 +8,120 @@
 / {
 	compatible = "brcm,bcm2835";
 	fragment@0 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=256M";
-		};
-	};
-	fragment@1 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=192M";
-		};
-	};
-	fragment@2 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=128M";
-		};
-	};
-	fragment@3 {
-		target-path = "/chosen";
+		target = <&cma>;
 		__overlay__ {
-			bootargs = "cma=96M";
+			size = <100663296>;
 		};
 	};
-	fragment@4 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=64M";
-		};
-	};
-	fragment@5 {
+	fragment@1 {
 		target = <&ddc0>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@6 {
+	fragment@2 {
 		target = <&ddc1>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@7 {
+	fragment@3 {
 		target = <&hdmi0>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@8 {
+	fragment@4 {
 		target = <&hdmi1>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@9 {
+	fragment@5 {
 		target = <&hvs>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@10 {
+	fragment@6 {
 		target = <&pixelvalve0>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@11 {
+	fragment@7 {
 		target = <&pixelvalve1>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@12 {
+	fragment@8 {
 		target = <&pixelvalve2>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@13 {
+	fragment@9 {
 		target = <&pixelvalve3>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@14 {
+	fragment@10 {
 		target = <&pixelvalve4>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@15 {
+	fragment@11 {
 		target = <&v3d>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@16 {
+	fragment@12 {
 		target = <&vc4>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@17 {
+	fragment@13 {
 		target = <&txp>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
-	fragment@18 {
+	fragment@14 {
 		target = <&fb>;
 		__overlay__ {
 			status = "disabled";
 		};
 	};
-	fragment@19 {
+	fragment@15 {
 		target = <&firmwarekms>;
 		__overlay__ {
 			status = "disabled";
 		};
 	};
-	fragment@20 {
+	fragment@16 {
 		target = <&vec>;
 		__overlay__ {
 			status = "disabled";
 		};
 	};
-	fragment@21 {
+	fragment@17 {
 		target = <&hdmi0>;
 		__dormant__ {
 			dmas;
 		};
 	};
-	fragment@22 {
+	fragment@18 {
 		target = <&hdmi1>;
 		__dormant__ {
 			dmas;
 		};
 	};
-	fragment@23 {
+	fragment@19 {
 		target = <&usb>;
 		#address-cells = <1>;
 		#size-cells = <1>;
--- a/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts
+++ b/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts
@@ -5,77 +5,36 @@
 /dts-v1/;
 /plugin/;
 
+#include "cma-overlay.dts"
+
 / {
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
-		target-path = "/chosen";
-		__overlay__ {
-			bootargs = "cma=256M";
-		};
-	};
-
 	fragment@1 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=192M";
-		};
-	};
-
-	fragment@2 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=128M";
-		};
-	};
-
-	fragment@3 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=96M";
-		};
-	};
-
-	fragment@4 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=64M";
-		};
-	};
-
-	fragment@5 {
 		target = <&fb>;
 		__overlay__  {
 			status = "disabled";
 		};
 	};
 
-	fragment@6 {
+	fragment@2 {
 		target = <&firmwarekms>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@7 {
+	fragment@3 {
 		target = <&v3d>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@8 {
+	fragment@4 {
 		target = <&vc4>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
-
-	__overrides__ {
-		cma-256 = <0>,"+0-1-2-3-4";
-		cma-192 = <0>,"-0+1-2-3-4";
-		cma-128 = <0>,"-0-1+2-3-4";
-		cma-96  = <0>,"-0-1-2+3-4";
-		cma-64  = <0>,"-0-1-2-3+4";
-	};
 };
--- a/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
+++ b/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
@@ -7,108 +7,75 @@
 
 #include <dt-bindings/clock/bcm2835.h>
 
+#include "cma-overlay.dts"
+
 / {
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
-		target-path = "/chosen";
-		__overlay__ {
-			bootargs = "cma=256M";
-		};
-	};
-
 	fragment@1 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=192M";
-		};
-	};
-
-	fragment@2 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=128M";
-		};
-	};
-
-	fragment@3 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=96M";
-		};
-	};
-
-	fragment@4 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=64M";
-		};
-	};
-
-	fragment@5 {
 		target = <&i2c2>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@6 {
+	fragment@2 {
 		target = <&fb>;
 		__overlay__  {
 			status = "disabled";
 		};
 	};
 
-	fragment@7 {
+	fragment@3 {
 		target = <&pixelvalve0>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@8 {
+	fragment@4 {
 		target = <&pixelvalve1>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@9 {
+	fragment@5 {
 		target = <&pixelvalve2>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@10 {
+	fragment@6 {
 		target = <&hvs>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@11 {
+	fragment@7 {
 		target = <&hdmi>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@12 {
+	fragment@8 {
 		target = <&v3d>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@13 {
+	fragment@9 {
 		target = <&vc4>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@14 {
+	fragment@10 {
 		target = <&clocks>;
 		__overlay__  {
 			claim-clocks = <
@@ -120,21 +87,21 @@
 		};
 	};
 
-	fragment@15 {
+	fragment@11 {
 		target = <&vec>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@16 {
+	fragment@12 {
 		target = <&txp>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@17 {
+	fragment@13 {
 		target = <&hdmi>;
 		__dormant__  {
 			dmas;
@@ -142,11 +109,6 @@
 	};
 
 	__overrides__ {
-		cma-256 = <0>,"+0-1-2-3-4";
-		cma-192 = <0>,"-0+1-2-3-4";
-		cma-128 = <0>,"-0-1+2-3-4";
-		cma-96  = <0>,"-0-1-2+3-4";
-		cma-64  = <0>,"-0-1-2-3+4";
 		audio   = <0>,"!17";
 	};
 };
--- a/arch/arm/boot/dts/overlays/vc4-kms-v3d-pi4-overlay.dts
+++ b/arch/arm/boot/dts/overlays/vc4-kms-v3d-pi4-overlay.dts
@@ -7,164 +7,131 @@
 
 #include <dt-bindings/clock/bcm2835.h>
 
+#include "cma-overlay.dts"
+
 / {
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
-		target-path = "/chosen";
-		__overlay__ {
-			bootargs = "cma=256M";
-		};
-	};
-
 	fragment@1 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=192M";
-		};
-	};
-
-	fragment@2 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=128M";
-		};
-	};
-
-	fragment@3 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=96M";
-		};
-	};
-
-	fragment@4 {
-		target-path = "/chosen";
-		__dormant__ {
-			bootargs = "cma=64M";
-		};
-	};
-
-	fragment@5 {
 		target = <&ddc0>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@6 {
+	fragment@2 {
 		target = <&ddc1>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@7 {
+	fragment@3 {
 		target = <&hdmi0>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@8 {
+	fragment@4 {
 		target = <&hdmi1>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@9 {
+	fragment@5 {
 		target = <&hvs>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@10 {
+	fragment@6 {
 		target = <&pixelvalve0>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@11 {
+	fragment@7 {
 		target = <&pixelvalve1>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@12 {
+	fragment@8 {
 		target = <&pixelvalve2>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@13 {
+	fragment@9 {
 		target = <&pixelvalve3>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@14 {
+	fragment@10 {
 		target = <&pixelvalve4>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@15 {
+	fragment@11 {
 		target = <&v3d>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@16 {
+	fragment@12 {
 		target = <&vc4>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@17 {
+	fragment@13 {
 		target = <&txp>;
 		__overlay__  {
 			status = "okay";
 		};
 	};
 
-	fragment@18 {
+	fragment@14 {
 		target = <&fb>;
 		__overlay__  {
 			status = "disabled";
 		};
 	};
 
-	fragment@19 {
+	fragment@15 {
 		target = <&firmwarekms>;
 		__overlay__  {
 			status = "disabled";
 		};
 	};
 
-	fragment@20 {
+	fragment@16 {
 		target = <&vec>;
 		__overlay__  {
 			status = "disabled";
 		};
 	};
 
-	fragment@21 {
+	fragment@17 {
 		target = <&hdmi0>;
 		__dormant__  {
 			dmas;
 		};
 	};
 
-	fragment@22 {
+	fragment@18 {
 		target = <&hdmi1>;
 		__dormant__  {
 			dmas;
@@ -172,12 +139,7 @@
 	};
 
 	__overrides__ {
-		cma-256 = <0>,"+0-1-2-3-4";
-		cma-192 = <0>,"-0+1-2-3-4";
-		cma-128 = <0>,"-0-1+2-3-4";
-		cma-96  = <0>,"-0-1-2+3-4";
-		cma-64  = <0>,"-0-1-2-3+4";
-		audio   = <0>,"!21";
-		audio1   = <0>,"!22";
+		audio   = <0>,"!17";
+		audio1   = <0>,"!18";
 	};
 };