2
0

0010-MIPS-add-bootargs-override-property.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From f15d27f9c90ede4b16eb37f9ae573ef81c2b6996 Mon Sep 17 00:00:00 2001
  2. From: David Bauer <[email protected]>
  3. Date: Thu, 31 Dec 2020 18:49:12 +0100
  4. Subject: [PATCH] MIPS: add bootargs-override property
  5. Add support for the bootargs-override property to the chosen node
  6. similar to the one used on ipq806x or mpc85xx.
  7. This is necessary, as the U-Boot used on some boards, notably the
  8. Ubiquiti UniFi 6 Lite, overwrite the bootargs property of the chosen
  9. node leading to a kernel panic when loading OpenWrt.
  10. Signed-off-by: David Bauer <[email protected]>
  11. ---
  12. arch/mips/kernel/setup.c | 30 ++++++++++++++++++++++++++++++
  13. 1 file changed, 30 insertions(+)
  14. --- a/arch/mips/kernel/setup.c
  15. +++ b/arch/mips/kernel/setup.c
  16. @@ -571,8 +571,28 @@ static int __init bootcmdline_scan_chose
  17. return 1;
  18. }
  19. +static int __init bootcmdline_scan_chosen_override(unsigned long node, const char *uname,
  20. + int depth, void *data)
  21. +{
  22. + bool *dt_bootargs = data;
  23. + const char *p;
  24. + int l;
  25. +
  26. + if (depth != 1 || !data || strcmp(uname, "chosen") != 0)
  27. + return 0;
  28. +
  29. + p = of_get_flat_dt_prop(node, "bootargs-override", &l);
  30. + if (p != NULL && l > 0) {
  31. + strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
  32. + *dt_bootargs = true;
  33. + }
  34. +
  35. + return 1;
  36. +}
  37. +
  38. static void __init bootcmdline_init(char **cmdline_p)
  39. {
  40. + bool dt_bootargs_override = false;
  41. bool dt_bootargs = false;
  42. /*
  43. @@ -586,6 +606,14 @@ static void __init bootcmdline_init(char
  44. }
  45. /*
  46. + * If bootargs-override in the chosen node is set, use this as the
  47. + * command line
  48. + */
  49. + of_scan_flat_dt(bootcmdline_scan_chosen_override, &dt_bootargs_override);
  50. + if (dt_bootargs_override)
  51. + return;
  52. +
  53. + /*
  54. * If the user specified a built-in command line &
  55. * MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is
  56. * prepended to arguments from the bootloader or DT so we'll copy them