From patchwork Sat Oct 22 21:13:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 7940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1357015wrr; Sat, 22 Oct 2022 14:17:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SU30Qxnng8YLgn9vLDFV9qFWqusiO5Q5TU1eDIxRjCkLoLknWutp/COT3tcVLRrGyEmjL X-Received: by 2002:a17:906:5daa:b0:78e:2bc7:f1a3 with SMTP id n10-20020a1709065daa00b0078e2bc7f1a3mr20594758ejv.256.1666473457475; Sat, 22 Oct 2022 14:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666473457; cv=none; d=google.com; s=arc-20160816; b=sFojaBPLyf3PkTstILUYy6+6a94UpFz/U2suJOkkiSPB1/envHtzuwOY+cRL13UoDF BH9ntgwggvYcdaTjQgwj+pvD9dVYYlTD2ednIRYoik3/JanNDSxQ+kbCDId9bhfnPoe8 wN3DS+xUU7WSnVfKAJA4QDsdz6Iwy236p8Fkalt1w76fZts/rSFct9xv3yZ6Uor9MWTU zIhZsbhmCUr46uqCk2Jw8bKewkHb/DNw44XSM860WlJ6eANR83J1w64SfdSD6LMMgA8F c/0ZGCJsvgtdmJBuw4ydeEZQSvg2TCfweR/zwzhYgw/2joyj5Kpi3Q5UbpuJEn6ol6ct Xcqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=C5hHs2S/RQl/JXIwHudGm/5mav5RsuOJ5skKbHJaT7M=; b=X/8g36iMRvp/QtLY6RRkX2Gfg+Qt7qivTwylrGtdC+crvKNVp8n4bm6P2tP7J7CTpZ HLk3vDsGculUB3v1H/zn9GEWj1xWazjIYC1GMzWJpKBJsfC6M8coOBhb+elvBHkpqHsn tWA3iSLA5BwK2MqFV2YrED2Iubb5u1nLQo8grkhljU1fBcfXMzxkZh6gRpqPohqi/x8P y3E3WNiAYfsd4wTM7uzBThNmygE4omW9K8nP+3aOfocsbyxZZjMnGebf7jmv2mRSqO3a ONYf/BUBfbDKsCjip1aJKuq2uyuNHfvz/eyS+UOYMHHGSvXVoMT8SuEJi9lt6QBBOHYZ qzJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NmBEE6eF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb22-20020a170907961600b0072fc714c92fsi25181783ejc.902.2022.10.22.14.17.13; Sat, 22 Oct 2022 14:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NmBEE6eF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbiJVVNa (ORCPT + 99 others); Sat, 22 Oct 2022 17:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiJVVN2 (ORCPT ); Sat, 22 Oct 2022 17:13:28 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FBC7FF9A; Sat, 22 Oct 2022 14:13:25 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id u21so18125343edi.9; Sat, 22 Oct 2022 14:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=C5hHs2S/RQl/JXIwHudGm/5mav5RsuOJ5skKbHJaT7M=; b=NmBEE6eFFqAk065UYolm1o7PT0D3spxPjIpTB1GN4doSOzS/VyF0MqEGtviFaTzcZc kkyskhusTgRHUEXA+SUJWNZZZMtBpySOqUoLqvRB5ZBLRjhEc9KjhLe9c5jK8ry4uTV2 Nk789OK4t4+qNfxNc4QY99Syb9ofJ5Ow89nccso5G+zA4tp0VGicKZTAp9x+JY0nIJAz F+e7O3kIGx94sm6tXjxLuCdaD+lqhx63E8T/5sM8hYbr3w3szKdM8Thn11CAbYOPpln1 t8lbqWF+RU+6NYlfHw/1fmuOYBoXOLkZUGM3TezeU14AoBjoAJHSGDkc9AdSC9EA9b48 y46Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=C5hHs2S/RQl/JXIwHudGm/5mav5RsuOJ5skKbHJaT7M=; b=mCVrS0wvWRyrbI4uwJMat0y8A+hV0Qo4FncYjVra9n6IZRI08gR2dhjsgPeD4mW0RN IGu9putT6zFaJGgkWwM72sBxrWh1k5tyQOe/1vwXjqtZlfPzR1StnC3W96pMWKx8ueMZ AtUZii6TxNR7Yerg1Ec/zXwrOsH5Ns7/isTLvnRmULg6cVx7r+1rOlmJr3p0s9bFeE65 cI0pbGBl3N4o2QxKtvo8l++XRd9A8aBqWpwSJjvULDZhOhauc+XLmv1AGdDtfSPnACxJ EzNL1h4UHF74/v0Pb0CxusB0ReJ8r4+5wE5+Uu549mKJAb8Plfn+QOmUn5qDWQubY3tQ XPag== X-Gm-Message-State: ACrzQf2u5hf2EAQYk02M//TkbooW2wThRO+dsYGUP5o4JYi9WdOTQ+rN IYIyBSEYhAVsnkIzrHEzKVc= X-Received: by 2002:a17:907:3f23:b0:78e:260a:fc33 with SMTP id hq35-20020a1709073f2300b0078e260afc33mr21579377ejc.152.1666473203739; Sat, 22 Oct 2022 14:13:23 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id la5-20020a170907780500b0077f20a722dfsm13382584ejc.165.2022.10.22.14.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 14:13:23 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski Cc: Mikhail Zhilkin , Christian Marangi , Wolfram Sang , Chaitanya Kulkarni , "Martin K . Petersen" , Jens Axboe , Andrew Morton , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V3 1/2] dt-bindings: mtd: partitions: support marking rootfs partition Date: Sat, 22 Oct 2022 23:13:17 +0200 Message-Id: <20221022211318.32009-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747424071807013035?= X-GMAIL-MSGID: =?utf-8?q?1747424071807013035?= From: Rafał Miłecki Linux needs to know what to use as root device. On embedded devices with flash the only common way to specify that is cmdline & root= parameter. That solution works with U-Boot which is Linux & cmdline aware but isn't available with all market bootloaders. Also that method is fragile: 1. Requires specific probing order on multi-flash devices 2. Uses hardcoded partitions indexes A lot of devices use different partitioning methods. It may be "fixed-partitions" or some dynamic partitioning (e.g. based on parts table). For such cases allow "linux,rootfs" property to mark correct flash partition. Signed-off-by: Rafał Miłecki Reviewed-by: Rob Herring --- V2: Use "linux,rootfs" as more accurate. Thanks Rob. --- .../devicetree/bindings/mtd/partitions/fixed-partitions.yaml | 1 + .../devicetree/bindings/mtd/partitions/partition.yaml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml index ad3ccd250802..d66a6e3bcb56 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml @@ -84,6 +84,7 @@ examples: partition@0 { label = "filesystem"; reg = <0x00000000 0x1 0x00000000>; + linux,rootfs; }; }; diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml index f1a02d840b12..a25cd23a34c0 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml @@ -52,6 +52,10 @@ properties: immune to paired-pages corruptions type: boolean + linux,rootfs: + description: Marks partition that contains root filesystem to mount and boot + user space from + if: not: required: [ reg ] From patchwork Sat Oct 22 21:13:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 7941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1357096wrr; Sat, 22 Oct 2022 14:17:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UaXgAfNs8aLXUM1gm4iO2U9jGgDhCe/0H1rtErymQrEJlaJU6ejHB/Sx6NxxTdjkasxOP X-Received: by 2002:a05:6402:194d:b0:461:8982:52b8 with SMTP id f13-20020a056402194d00b00461898252b8mr2886810edz.49.1666473476450; Sat, 22 Oct 2022 14:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666473476; cv=none; d=google.com; s=arc-20160816; b=y610hSTWE1LYUMD9pKpnauANIMTaeDCjk1P2q8QZ2aM2lkVd+g7LDnoFJCD1riXUKm P/ZGzzm7krqW43y5rBYWm+KqWbLmQhS82TFz4tYpcasTswftJn0sBLddrQq8KSxlAO5s 9eiojl72Uw7Wl5BYHpUKUPaHW1RF7ixditaab7D8pWk7C+fPX3OP4AS7xss9C1eJ9gdp GYD9Yh4zBewao14CKJ4ewMCq5sGajQfdJraNILw00ctsg/Z/6a/NMHEA1ZLW5oTRewmY WyZxVT3FeE6kLVJ95Fc3qDbPAwZl9FkhhDEZmq1JW/jDZFKLHWgm/33WzWHZQdNmzb7S 6DOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sMcPWSUmJnWN6Xepe9O23Js1qxdW09hzjNuw8smzgps=; b=bpq2mubEwIP+h68MbqabloQpROH1/Vyj6cLDW+9LgaQ/a1KGnp50ZI1mks26TBqkL2 AHxuME+exbDXjaCyuKGXMRrak1y6KrNNriKiZ1Lpfkf85VCm3WwGN/eXP0w5AN3ZOOYd SRoLbWztY0Be6ZEgZl6HPUvj59v3hgaGWnObXSZlj4Jq1yeUh6c48xH4ed1v4zJahMfn HnwdQ80Opkwk7ybteSI1V+T7wbervAvAMN6ejHb2uUVhQ2aYuqeXyirGLJEAldeGML72 nvTVU5dStodrcUVc2b0/72xBxAVnUWqQNuWc3NeEvJiaPnMEAw6iOkYzZGFKSYFuren2 ePtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Juwv+t1R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne22-20020a1709077b9600b007701a050273si27395358ejc.942.2022.10.22.14.17.32; Sat, 22 Oct 2022 14:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Juwv+t1R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbiJVVNc (ORCPT + 99 others); Sat, 22 Oct 2022 17:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiJVVN3 (ORCPT ); Sat, 22 Oct 2022 17:13:29 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA9E80497; Sat, 22 Oct 2022 14:13:26 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id b12so18143932edd.6; Sat, 22 Oct 2022 14:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=sMcPWSUmJnWN6Xepe9O23Js1qxdW09hzjNuw8smzgps=; b=Juwv+t1RTD/CMonD6c03dxDghAH5fYtIui194P1sOuPDqUipKVcMtYq5xsIHFnFu/S 9PuKQH+IEKm9pjZCdY5rKHFMux6oZ6jGSl/kLkoOPzGiCObsf8o8V/BIs4ImZJ24157x vCJ4/stysEk6t20lEO+Guu/3orvGzmm07igbOeQdiKL4A/gMqz8qTwo/gO00Xc+5hgnY D+/QqytyJcYHxhBW/nZccJUnnNV3z2H4Zzo2XIG5Z0M9/WfLUgZfnTa6297r6BzOL5J0 75kjjA5hJtnpm2S/eHxSYDOqznebiuBAghHKBcvY38HOpjFsUNzasVI9q7LASA5P552b gExg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=sMcPWSUmJnWN6Xepe9O23Js1qxdW09hzjNuw8smzgps=; b=D7ovd6hZv6ecopDN87AxzAtSEIRROEJ4ZnBq3Htyyvq/Z/URyuIVbZAjA/GMVdCyrl jmchuw41vOvvtvSoA9WdpdzHt7VzVI1SYG040mU38lWf8J2pSgLvH8fG1YgWch/yD2Bv pXEidRJpn1x9EZUGxb08k62EIp/Uqy+vM/yVT8iXAsN/uMPwgLGA0apC5Dsh68ExJHjX UfkSeqHzt/RyvUpygUQgzzYKEFYQhgPQ9exd2e6EOQq0qtZFHhUFZcaIrS07omGh6ECp iH+e+Qx+6Iuzx8onT6EyaWi/SGX0IbPKIDZNqmOop9DMl/kFEFepgoRXaCHFIGl4D/HP HFYQ== X-Gm-Message-State: ACrzQf2hAt8jCHBAy8WPMBywUpy+54kUldRy4y43/lAkCMxa8aTQVmee Xy4U7oMINmK5yCebKX60Nl4= X-Received: by 2002:a50:ed03:0:b0:461:9f73:b8d9 with SMTP id j3-20020a50ed03000000b004619f73b8d9mr857808eds.140.1666473205425; Sat, 22 Oct 2022 14:13:25 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id la5-20020a170907780500b0077f20a722dfsm13382584ejc.165.2022.10.22.14.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 14:13:25 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski Cc: Mikhail Zhilkin , Christian Marangi , Wolfram Sang , Chaitanya Kulkarni , "Martin K . Petersen" , Jens Axboe , Andrew Morton , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V3 2/2] mtd: core: set ROOT_DEV for partitions marked as rootfs in DT Date: Sat, 22 Oct 2022 23:13:18 +0200 Message-Id: <20221022211318.32009-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221022211318.32009-1-zajec5@gmail.com> References: <20221022211318.32009-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747424091948461566?= X-GMAIL-MSGID: =?utf-8?q?1747424091948461566?= From: Rafał Miłecki This adds support for "linux,rootfs" binding that is used to mark flash partition containing rootfs. It's useful for devices using device tree that don't have bootloader passing root info in cmdline. Signed-off-by: Rafał Miłecki --- V2: Use "linux,rootfs" as more accurate. Thanks Rob. V3: Add IS_BUILTIN(CONFIG_MTD) check to avoid ERROR: modpost: "ROOT_DEV" [drivers/mtd/mtd.ko] undefined! --- drivers/mtd/mtdcore.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 20fcedc3021e..f70a5e66843b 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -735,6 +736,17 @@ int add_mtd_device(struct mtd_info *mtd) not->add(mtd); mutex_unlock(&mtd_table_mutex); + + if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) { + if (IS_BUILTIN(CONFIG_MTD)) { + pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name); + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index); + } else { + pr_warn("mtd: can't set mtd%d (%s) as root device - mtd must be builtin\n", + mtd->index, mtd->name); + } + } + /* We _know_ we aren't being removed, because our caller is still holding us here. So none of this try_ nonsense, and no bitching about it