From patchwork Sun May 12 13:25:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662728 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFC17C8E1; Sun, 12 May 2024 13:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520328; cv=none; b=liNn1m8ljTi+VZBJIp0rG2HN+U2/kxgyy36Foz2G88Dho5ICKKDkvq2ZrT/T9+1AJ1xHXLDwC5mI/FApceZ+s1cymmqlKsufMb1XGRaSVPug1bRmJWytuOa/jQgfthKWec9cczZlWRJNtkPTKhv3Q94wE1pZB8xW/xbPG9/H+ZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520328; c=relaxed/simple; bh=ziuxodXmZqtpeLyT3WRo0HQ7ERm9YtUUFoZCGeXGEns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gZiyw3NvI9MqmWxwRS5mfsDlLY188dYwQET54U8x3fy8gN4SRl/E9wsd3Q6Lgj0lKyDECqDcjHQnwLnr+47EF8qasWS0flwAjVHi92enDQjgzOpujKp8aHBGQ3cnFXFlUc1gncjRwUgi3FVZ0+8l0RxF93k83h29qdpDyiYf9bA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dVpxueMz; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dVpxueMz" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-34ddc9fe497so2147469f8f.3; Sun, 12 May 2024 06:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715520325; x=1716125125; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sL/fOKJNE13f8s8Vxmy3Xn7MqVMQgv+JZ4dwjBfG/fg=; b=dVpxueMzVjzLUPpmy+QZ1BurCK+LoRkqSf6Dihmckx3lXiG5tiY2aVy3+nGzl2NSVL 1ipI3muJWpZMoTuTYDoDi5y+oSCZ4O0sQizarKGZFTgDl9VSah5iogDbLr6LjtQTv4mD J8NVXZ2TvU7FTveB+P0hQG0cz40UrQJT/biXa8MlKxJmTTPVk2nvBl63MDi+gkxF7Tbb D3md4j+b1cQeAKJqYrHDNSYfz56GKaEyCrYTnV4/NyC7qWOHH7R+cPEQIgAWBq7O8pqi /rLdp4zuFKfyAhk1I+vZYX1F3+8saZcDv3/vYj1oROIMiFAenx8dYikjWx/Uz+Gn/THc Foww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715520325; x=1716125125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sL/fOKJNE13f8s8Vxmy3Xn7MqVMQgv+JZ4dwjBfG/fg=; b=cAc+T6XSBM/TABfz7wWtYadcRfls1YoXZBzclVjvp025uts2GP/jesGmJEPJ8frHZ3 5ZEza0fCmeyLaTy4WqNOvyAmB0P4F1d1WDwf4maYOzu6NkJue0nT3Ajo9DI8iPYUljwU oeS099fXYZW/052Tp4FXkLbF+oCIoEH15x2ZjruwftZ388xfLP+S/GUHaobOe07k8ROo XvIfEZffzMBlSofUc82EiX0xhi9b/sXzl/xfeG4wERgcL7omk+pS3Wgdz9X6tPzg/4hE Bk/Izim/8yzHmUoW1oOs/YY1H3/nzqrwtKG0c2YALpUJ0yErDeNyWyh82Q/Ov/wS0dpL i0dw== X-Forwarded-Encrypted: i=1; AJvYcCUj5xXDC/c5ez5O+VlQO2fhVs1r7NALOLDwttEZudMNRXc3ie9mKGDLYrDqqT942XkFGB9Rg9bIxutLSKvVRjkH42sXWp0vO5+nFAschnxZZeIdhYXDViMQ8x9OJd5Hi1FBzzFWkzayrVn2LJ7m2mPtx3X49HQoSh0Z7kIy/y6ufC3JYsc= X-Gm-Message-State: AOJu0YxKqtWmSmzzYxPqVpoCMY6Atu6kqbCNFdfki5HVSOkKtXSsO3xA PNZcXBavQTjTYikTmjZ684ne9FU3vF1iI57bp8y+rl/h+eiL0Sas X-Google-Smtp-Source: AGHT+IHRdHyZ3PlbbID/Gfd5cytQkO0BDMgpUZIJTDGo/+a9zih+tJjE0OnxVFh20DOAOFoJ351Fag== X-Received: by 2002:a5d:4f91:0:b0:34c:fa17:f4fe with SMTP id ffacd0b85a97d-3504a632b42mr7190063f8f.21.1715520324938; Sun, 12 May 2024 06:25:24 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3502b79bd09sm8822468f8f.14.2024.05.12.06.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 06:25:24 -0700 (PDT) From: Christian Marangi To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer , Saravana Kannan , Arnd Bergmann , Helge Deller , Javier Martinez Canillas , Baoquan He , Thomas Gleixner , Jiaxun Yang , David Bauer , Liviu Dudau , Serge Semin , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Christian Marangi Subject: [PATCH 1/4] docs: dt: Document new bootargs chosen property Date: Sun, 12 May 2024 15:25:08 +0200 Message-ID: <20240512132513.2831-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240512132513.2831-1-ansuelsmth@gmail.com> References: <20240512132513.2831-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The bootargs property might be overridden by bootloaders on kernel load, in such scenario, bootargs-override might be used instead. With bootargs-override set, any value set in bootargs will be ignored. The bootargs-append can be used to append additional kernel arguments to the bootargs property. This can be useful in the context of a bootargs overridden by the bootloader that contains correct that but the kernel require additional one to be correctly setup. Signed-off-by: Christian Marangi --- Documentation/devicetree/usage-model.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/usage-model.rst b/Documentation/devicetree/usage-model.rst index 0717426856b2..885be3e582fc 100644 --- a/Documentation/devicetree/usage-model.rst +++ b/Documentation/devicetree/usage-model.rst @@ -217,6 +217,15 @@ On ARM, the function setup_machine_fdt() is responsible for early scanning of the device tree after selecting the correct machine_desc that supports the board. +The bootargs property might be overridden by bootloaders on kernel load, +in such scenario, bootargs-override might be used instead. With +bootargs-override set, any value set in bootargs will be ignored. + +The bootargs-append can be used to append additional kernel arguments +to the bootargs property. This can be useful in the context of a +bootargs overridden by the bootloader that contains correct that but +the kernel require additional one to be correctly setup. + 2.4 Device population --------------------- After the board has been identified, and after the early configuration data From patchwork Sun May 12 13:25:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662729 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC120224FA; Sun, 12 May 2024 13:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520329; cv=none; b=b+ruF0PWsNcY2aQ8xWQ/svWNjoNH4A8/T2jlusnX+yX4mHbOCg6Si6sbL5qXI2R8zetOUDLqhXEDBDpm03ON1OnCFq0msA/CJYLTc5uikVxorsQZqpPEsLmB72JwtCyTKrnAZOKN6Ug7p6UbQx7+4xLZfIAdm9mKJZDegAQqY80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520329; c=relaxed/simple; bh=cULXUs4oYMOgR/QBf90+qkWOo4Cgu5Y9M6vv7b9LZ54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQOHIUeZRaW00UZd04RGAOOv4dVbCNm7AzHlSY6PXIqEyUm8VavV/JqWRkIkD2rHldJUpcBCslWSBpJA57dCA4jzGQp8KiXY+AJP782OBJF9AzyzFiID7EIgUEge3E4ri36oDIM+VV+/6b6T0NPKgBewsN+r+5N0sUQqCprs1vY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=beEkSMMB; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="beEkSMMB" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3504ad82a64so1890885f8f.3; Sun, 12 May 2024 06:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715520326; x=1716125126; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J5Pmi57zjaY4Bk3X2+sKkul6hm94IvXCLST+UV4b4aI=; b=beEkSMMBOl7nrB1FYwJ/n8gl9gSvFQFZoLpJA6MWul10N1W+e/O/nHRENk5QInLY4E hKb5XsbqbDjzf1ep9P1nDzpeCn/FI1oHjEQPFimcfiYwIjIwCqvsljoNqcwA4bpbqVv3 LV9sFLV4r/cFMCHs0nhQYXbVz/Ru7NxPdlWQeJ53/ZfcLrf73kpwgHBSnLTc8s94HAR+ O4T+Ws1QNWQWGzoDeTpO8NkcAInPv2vI9gPxp4gwh9P8bdNWwk1GuI7BKgjHkT33NZvw BqYTiuNofjWO9jPKRKCa/CI43ULTEXRruyLKQeB5eRJJYVzKewyhFsx6M70WoKVjQhwX ZzQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715520326; x=1716125126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J5Pmi57zjaY4Bk3X2+sKkul6hm94IvXCLST+UV4b4aI=; b=EVEAOyrVicYc8i/ndoMYPD56ezcRA3hcvT4WwQxZPlUNIzsinU0xXVoq0UwbJch409 aPZiwPwRfaDyvBfuvk2SjrcjPaMQBiBcayQ8+XhN21x9nTLvqMyOc3llxVKwqhVjK9Dr EmcT0dPewLM034lk8v5U0plzo0dnUpYcFEIDHbqvTWYVdGxKos8m559164kun4KfSOCw D5XoYO4RXDdDVEWPDfBebzluQB4yROWR5g2/kUPdnzBizlI40YgXD4aeVXp9E27JVMR+ kcer2Z9WQrY6QV2QtXUdV9TXZwRVxPS0kKxOLSQAxfmQvF3dvq7ziwT0jq9uZd8Hv9Qw lqNQ== X-Forwarded-Encrypted: i=1; AJvYcCWRbSpSlFvbdInxcl8Fsz5LIvwWM3RREp35B1/VnGL7nTggi/ewP9Gj2JPnfgwsog33LSnqrnZWRaUL8rnG7/ZTYbpns68gIoT7mMKzftD0QVnX/I6wFbHr9EugN5/D2nwyD/es44hgEDNraHgyqFHFxPnrzNXoUWjPKSQpMgR9KEXFPJs= X-Gm-Message-State: AOJu0YxqdygPrYzF9hYL1qMWO08SDbR/o/tulPFGu2UInCSNLNstZLR0 +4WyerI1yh6xs6QWnwJ/yfOXvM9BwqbIrKNcW4ZrIsKTEGTOrnst X-Google-Smtp-Source: AGHT+IHG3/XRd6IxAw7eUmVcc5xbSl2lr2OFca3ps7nBLqxTUog370gaVqi8bvEvtL3Tmt7Vfk5big== X-Received: by 2002:adf:f10e:0:b0:343:e52a:f51e with SMTP id ffacd0b85a97d-3504a954dc2mr4494750f8f.47.1715520326176; Sun, 12 May 2024 06:25:26 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3502b79bd09sm8822468f8f.14.2024.05.12.06.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 06:25:25 -0700 (PDT) From: Christian Marangi To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer , Saravana Kannan , Arnd Bergmann , Helge Deller , Javier Martinez Canillas , Baoquan He , Thomas Gleixner , Jiaxun Yang , David Bauer , Liviu Dudau , Serge Semin , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Christian Marangi Subject: [PATCH 2/4] of: add support for bootargs-override chosen property Date: Sun, 12 May 2024 15:25:09 +0200 Message-ID: <20240512132513.2831-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240512132513.2831-1-ansuelsmth@gmail.com> References: <20240512132513.2831-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On some devices bootloader may hardcoded and overwrite the bootargs DT property passed in "/chosen" when the kernel is loaded resulting in the value dropped. While CMDLINE_FORCE can be used, this is not a good option for kernels that are shared across devices. This setting enables using "/chosen/bootargs-override" as the cmdline if it exists in the device tree. This broken behaviour was found in various devices from ipq806x Soc, to Mediatek and even PowerPC. Signed-off-by: Christian Marangi --- drivers/of/fdt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index a8a04f27915b..253315421591 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1068,8 +1068,16 @@ int __init early_init_dt_scan_chosen(char *cmdline) fdt_totalsize(initial_boot_params)); } - /* Retrieve command line */ - p = of_get_flat_dt_prop(node, "bootargs", &l); + /* + * Retrieve command line + * bootargs might be hardcoded and overwrite by bootloader on + * kernel load. + * Check if alternative bootargs-override is present instead + * first. + */ + p = of_get_flat_dt_prop(node, "bootargs-override", &l); + if (p == NULL || l == 0) + p = of_get_flat_dt_prop(node, "bootargs", &l); if (p != NULL && l > 0) strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); From patchwork Sun May 12 13:25:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662730 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E31F28E17; Sun, 12 May 2024 13:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520330; cv=none; b=ea61avFJaSipmV3KIrV4ul9WTLdZdrMlj1dc0hPcYjmnW1aZ+5NkQNhUMA3FA58lfE4DmvtMM5tFnk+44XEVFnG195aPk0/SQsDUjk2NukdxKiKD78GWM4m5QRGv1y75BRd0uQMfATtxyC2Q7B1dI+KolSQZE+SkSnbv2uOKE3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520330; c=relaxed/simple; bh=y5X0OWXz5ws3bAHMfoYFwbP2pMMbDn947glAeZm8OpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CZGZwBJyTVxHKMxzXODUoLXJ8NyPuy/eIp8IjgMnUVN1MXTRpZ4QsYQlccIAm7kWjbRwvxDHTLyoCa6r3+0czgjZ/6saUGUQCRQjGXDgc38x+RC0+3Y6a02/oOF4JGUD0IfmZygHsG4rwRRdyNcmwa48YA/xQs5x4WNjNt42oeo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A9Q+hvH1; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A9Q+hvH1" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-34db6a299b2so2838581f8f.3; Sun, 12 May 2024 06:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715520327; x=1716125127; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G276tR2DWdT7pXfSzU9VYLXPeNqUlLbGdFn/8pm75Rk=; b=A9Q+hvH1F8+WLk5zIzY8u4izwu3X1eNDxHp/xcDPz8hR/R08hbeQk5NLTBgCXuwKwP t0vUajJrEC5UBtdLk3DbUWENSNxs8ZNuJVB2MmEiU8+woAas5nTlDR5uHlMdOk5db4MI n8MbNMR4iXEvO92XIlb5kEByOeeLazkUMyEvx79m4xJZbHzktUCYp2C1wlmr2Uzsi0tq /qComxJJubY+XRZs05CNdvy2UoLoW589scNsmuYM27YVRlt1erP5nHdv1icwkrc8Xnwk 6oBLieVoC0fEHAsdagoYsFv7OLI6FjF1Ixx7xcZgVQlC3qVl5Lf/AhR4NuhzlfyLXNAc 4VVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715520327; x=1716125127; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G276tR2DWdT7pXfSzU9VYLXPeNqUlLbGdFn/8pm75Rk=; b=lrMPZ++O2f7+ejKQ4Oa4s1rqSLARLhEAb2JKT3s5huby29vspFKYFqpiul5+xyg8uX G/l4vCz4gE9umAxowYsEOHq81AY2mCpG1e0PK4JZlEIjcjflXhsKEpfLQKqvM+rxkX6y NWRz64lsyYIXrHEDhIsvg3o18KIrnFpLyIqMCoQO5q7WuQ9mMHtbMWbBN/rVZ0u5Etpv RgwN7Vgo9k21R+B1zahD5Yo/9LQp4l93+YTfO7FTXtbfIByxIxcB1Y9FyuyiX/dBoA1E KBEp35GZJIsc1bfmZfqQ6cmFBQYNWLoSSWksfKL7NYQNa/XV7gjaIdAlTMqKgPUFb0Ux 16LQ== X-Forwarded-Encrypted: i=1; AJvYcCVx4y4L1Y6+hx+QA4AVVQQEqJnc/+kEIpVEVSvmkubKjM9mQXF5gTfQBBDXadzvbGm/TUh6W6IHj9Kyns4yy3a97vqT1CPVz4T2r8QaO/4V7tnycSxRevw472y/0zAmZLB93WnYJDsLBdsyRWmbShIFNOQdWxHScepAQaFNZA2JfzNYVrU= X-Gm-Message-State: AOJu0Yytq/GCNEceJ2w1Rw/UobsUn2fSYwS+LqZ7hYJGiDlrd5S/r1Dr FsBosLPLPGjLAAhocMILdBxVdpPhczixnG4yWtwtyZpQITqvZWhK X-Google-Smtp-Source: AGHT+IHaRa+50aW0QoXfeIsR7gOwM/NZ4VO3b3Q2yRKNI3581ioshqLDSInjVS7DgPP8P6zle6v7ZQ== X-Received: by 2002:adf:e851:0:b0:34d:9fc2:4a81 with SMTP id ffacd0b85a97d-3504a61c5c6mr5321553f8f.5.1715520327427; Sun, 12 May 2024 06:25:27 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3502b79bd09sm8822468f8f.14.2024.05.12.06.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 06:25:27 -0700 (PDT) From: Christian Marangi To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer , Saravana Kannan , Arnd Bergmann , Helge Deller , Javier Martinez Canillas , Baoquan He , Thomas Gleixner , Jiaxun Yang , David Bauer , Liviu Dudau , Serge Semin , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Christian Marangi Subject: [PATCH 3/4] of: add support for bootargs-append chosen property Date: Sun, 12 May 2024 15:25:10 +0200 Message-ID: <20240512132513.2831-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240512132513.2831-1-ansuelsmth@gmail.com> References: <20240512132513.2831-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for bootargs-append chosen property. The bootargs-append can be used to append additional kernel arguments to the bootargs property. This can be useful in the context of a bootargs overridden by the bootloader that contains correct that but the kernel require additional one to be correctly setup. Signed-off-by: Christian Marangi --- drivers/of/fdt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 253315421591..cc99958872e4 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1080,6 +1080,9 @@ int __init early_init_dt_scan_chosen(char *cmdline) p = of_get_flat_dt_prop(node, "bootargs", &l); if (p != NULL && l > 0) strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); + p = of_get_flat_dt_prop(node, "bootargs-append", &l); + if (p != NULL && l > 0) + strlcat(cmdline, p, min_t(int, strlen(cmdline) + l, COMMAND_LINE_SIZE)); handle_cmdline: /* From patchwork Sun May 12 13:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662731 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6ED4B383A9; Sun, 12 May 2024 13:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520332; cv=none; b=luiZU7+6+CIuxgLXm5JU/KyGuqE++0XSjlPvKDu2vVlwmYzZz0BAMkUiy08CaE9DQAjwFGRtYeqVCUlGx6LpkEh8r6HS++aqiGppnI0nulbqLs+Yoo00w1gEM8j5YxH+jgiySjY8qD0hmbv29rx6Hu/NgsZ5rZKpuUQlQUA/MGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715520332; c=relaxed/simple; bh=J+g8IFFwy/vjVlcPhULbDtQ2VliUzl+7eSs2atsxppo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aBDECtxzE4A7Lqe9aKvLOC7RgS0UL9h828Cw7jJQXfuxULvpYroIQBjlMgULXPzWmI0+elJjDRHVn0OLgoVCWn1O3d+gvmhiaPSJHaVSHaEek660YBJsSh5GA9wkH78CDp8GX5KZ1CK4xBilHpqyEAsr4pQJeO/rv185SWZHivo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N29LfkAs; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N29LfkAs" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-34da4d6f543so2474888f8f.3; Sun, 12 May 2024 06:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715520329; x=1716125129; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BVMmxV0x3lE9AAJXo4i0SZvZEcFwdqyDwVz0Ae897gs=; b=N29LfkAsr/kAgpVCsgMQ7dMoFKgENWriyGYCSxUIWoRkyahowO9gnJqf2V/HuJstH6 /1xnaEZ2IDJ4eLp1a5PKUmPoX42MLwxUET1hvP/KIO5W4HJVFnm+uCqPmxml9XuASWGl wCOx4aeRfBzDvJhnKfLyYwc8Md/y6Z25ftaBeCinc9KWLv0fbSYPzQvU/F/8+2zHXFkn 1srgbp2FvsyK5J9qPkWrm2n+bmhEZTynlEoF1W0LDcC/TquHM3iHRwmkd0O9G/OnVjLa 4I8ebT1lLNLPRWYoUgKkbtJ85C3JwwbspblA5UwhBtHmWxcbMWmq4Mv/mHFLw/21VGtx sZoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715520329; x=1716125129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BVMmxV0x3lE9AAJXo4i0SZvZEcFwdqyDwVz0Ae897gs=; b=teKfkUNBtMOWYYLK/a4SHwbkcybFmQ17LsZDGrQPRIHX+50TGWZpvIiZ3Jtamky7Tn K+pZ2XOW2iKGYdx7H3lVf507wYsOX4Zgfn1g7WmPqFyiav3a3N3HuuSb+RbfFgXYyPmp sKwSCu5Dsfobs1TBKpa3Vo4oEEgGEd+T9tuZ4WKCQgD2DefSXGAcvOzi9OjffV7Vd7+B iDPosJpMh4wQo5zvTNSmTfuXjzgcEnIeslfzbppDKEZaD7mW7QvRpaRo425Q+YRG4vrO B0RvKVataEhot1yvcJqhldqTJuYo3poVsA4uMMhTVb6y3ztKQ6ROFzoethyOvzhUhMhh kIRg== X-Forwarded-Encrypted: i=1; AJvYcCX1PIDf54oKbuFex7hwmcOSiNzMbij543ZhHTLtaRUOtus4LSXxmHJeh/lClbS9GZFwIMbzMzUcbukAloViJ+Tv2nMzqzKgNPtS1Bp9B+Uw+wLGPzNf2C5mDvmEcVKYiC/AlIMIWPuQoG5J0eBiRa3dHnxgWiWVEdZvewrKDPB1OliimGc= X-Gm-Message-State: AOJu0Yz6JBG+63mReXg2mWty4IC2OHBYU5GcMVcDy+BOGDLVGAGqrTyW /qEQAeCIOCBnyvAyyCy/0UUPiKx/DteLRxcolnqHoHE2CO+eqjsm X-Google-Smtp-Source: AGHT+IGPgmj9+HFj7ZmEj4HsMNnaUpkxl+HBirbu9OeF3UbYZa3LMM4sHMUqN7Itsxvn58XENpHmLg== X-Received: by 2002:a05:6000:12d0:b0:34d:bbaf:27cf with SMTP id ffacd0b85a97d-3504a96a4b7mr5028390f8f.51.1715520328598; Sun, 12 May 2024 06:25:28 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3502b79bd09sm8822468f8f.14.2024.05.12.06.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 06:25:28 -0700 (PDT) From: Christian Marangi To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer , Saravana Kannan , Arnd Bergmann , Helge Deller , Javier Martinez Canillas , Baoquan He , Thomas Gleixner , Jiaxun Yang , David Bauer , Liviu Dudau , Serge Semin , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Christian Marangi Subject: [PATCH 4/4] MIPS: add bootargs-override property Date: Sun, 12 May 2024 15:25:11 +0200 Message-ID: <20240512132513.2831-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240512132513.2831-1-ansuelsmth@gmail.com> References: <20240512132513.2831-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: David Bauer Add support for the bootargs-override and bootargs-append property to the chosen node similar to the one used on ipq806x or mpc85xx. This is necessary, as the U-Boot used on some boards, notably the Ubiquiti UniFi 6 Lite, overwrite the bootargs property of the chosen node leading to a kernel panic on kernel loading (hardcoded root path or other not compatible thing). Signed-off-by: David Bauer [ rework and simplify implementation, add support for bootargs-append ] Signed-off-by: Christian Marangi --- arch/mips/kernel/setup.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 12a1a4ffb602..725e3f19f342 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -538,11 +538,23 @@ static int __init bootcmdline_scan_chosen(unsigned long node, const char *uname, (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) return 0; - p = of_get_flat_dt_prop(node, "bootargs", &l); + /* + * Retrieve command line + * bootargs might be hardcoded and overwrite by bootloader on + * kernel load. + * Check if alternative bootargs-override is present instead + * first. + */ + p = of_get_flat_dt_prop(node, "bootargs-override", &l); + if (p == NULL || l == 0) + p = of_get_flat_dt_prop(node, "bootargs", &l); if (p != NULL && l > 0) { bootcmdline_append(p, min(l, COMMAND_LINE_SIZE)); *dt_bootargs = true; } + p = of_get_flat_dt_prop(node, "bootargs-append", &l); + if (p != NULL && l > 0) + bootcmdline_append(p, min_t(int, strlen(boot_command_line) + l, COMMAND_LINE_SIZE)); return 1; }