314-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. @@ -564,8 +564,28 @@ static int __init bootcmdline_scan_chose
  17. #endif /* CONFIG_OF_EARLY_FLATTREE */
  18. +static int __init bootcmdline_scan_chosen_override(unsigned long node, const char *uname,
  19. + int depth, void *data)
  20. +{
  21. + bool *dt_bootargs = data;
  22. + const char *p;
  23. + int l;
  24. +
  25. + if (depth != 1 || !data || strcmp(uname, "chosen") != 0)
  26. + return 0;
  27. +
  28. + p = of_get_flat_dt_prop(node, "bootargs-override", &l);
  29. + if (p != NULL && l > 0) {
  30. + strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
  31. + *dt_bootargs = true;
  32. + }
  33. +
  34. + return 1;
  35. +}
  36. +
  37. static void __init bootcmdline_init(void)
  38. {
  39. + bool dt_bootargs_override = false;
  40. bool dt_bootargs = false;
  41. /*
  42. @@ -579,6 +599,14 @@ static void __init bootcmdline_init(void
  43. }
  44. /*
  45. + * If bootargs-override in the chosen node is set, use this as the
  46. + * command line
  47. + */
  48. + of_scan_flat_dt(bootcmdline_scan_chosen_override, &dt_bootargs_override);
  49. + if (dt_bootargs_override)
  50. + return;
  51. +
  52. + /*
  53. * If the user specified a built-in command line &
  54. * MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is
  55. * prepended to arguments from the bootloader or DT so we'll copy them