From patchwork Fri Oct 21 06:00:50 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: 6518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp510503wrr; Thu, 20 Oct 2022 23:04:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yx5u+SWCB/Bu4cAekAT+h50/vhnd0P6pOPDtc/fqRXk6yJJyl/Yj+qtIxmCVtCKFXM8hP X-Received: by 2002:aa7:cc90:0:b0:458:b07c:f35f with SMTP id p16-20020aa7cc90000000b00458b07cf35fmr15247561edt.310.1666332271392; Thu, 20 Oct 2022 23:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666332271; cv=none; d=google.com; s=arc-20160816; b=QPYyHuLBym/HlJkvdeIixe9bM5XGe3TkVYBXy47nMjRVxZLDrUrjLALk+RO2c1EgfA dWAI2xarjubzKsq5/io7uyBMvFchoBuD+2oaTcVtAYSQ6pz8Nx+xs65CnweUXJl3qj9x AMo+XighX96Bk0sPsyQFRJtWuunRdecsFuPgmsk2tgVds4GVEl4I+5Is3E420VRMNUe2 mbO3uv5gfnUDITlSwDPW49MeO9IIvWrK5+AObBu5kRwzOP0Q9lyY6e6UexBz0FeDUJ+5 TNrjmBaxNtYC57Bg4ranTLXmiu0wqiQDwDUj4HLeni21wNfNFVZ5W5Qp1OKWFnjr2OWy ebHg== 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=k/z4VWs7Sj0fnTt2ANjulFQt1nFieJXdwHALd4x8GUN3KMeL1k5UsH3N+5vP53GnhT Uy/jz3br1OoKYGz1V16zs/UOpduu4TadfjjaHUstmNGd8jJ+mVIX9QXDKpymtpUXf1c1 lZzg0KcxdGw7UIL+s6YVjYuDXdl0VTMIeAFPxHs1G7uZzhSaCqq6fcZsxsv4pgCuydEU IBP/PdvUFyzqt/kad30fGt4qdDJZ3HR42gPF1OAVGfo28sMw/j3uAz9jjZZvyqF+h2SS CbVByrD5OxGtEMI5ZihNcpoQ5THOuR/cRyBC0mEjWZKMTgl+e3+5xYVod6OTrqxWCN0Q 1TUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OYP1l1n6; 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 qb7-20020a1709077e8700b007721f88d3e0si19570241ejc.554.2022.10.20.23.04.06; Thu, 20 Oct 2022 23:04:31 -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=OYP1l1n6; 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 S229727AbiJUGBD (ORCPT + 99 others); Fri, 21 Oct 2022 02:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiJUGBC (ORCPT ); Fri, 21 Oct 2022 02:01:02 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1279A1A4003; Thu, 20 Oct 2022 23:00:58 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id g1so3272959lfu.12; Thu, 20 Oct 2022 23:00:57 -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=OYP1l1n6nvRFKN66YMNkW/ZD0biklmoqW7/GKmlBQ/5ENQhPpcHwgnW/rNIUjRoyeq mUi4KXWRSDufdZ1cvTW+/XnGUEaYLFilpxFrjNlzxEDxCFeoa4hoLVhGgnokrL4GUPet uKYNILHU9QWMrCKkaYtUezb0B7qpROKi1T0G3/hNigGE37igbdbYuW2uvo4prBisHInc RUEzuiYlVyFbUVo4KlAGbb6R/AWWoEOYu7HdZU0ekJPUOU2oH4HXT/NQl7KkNx7KZB/t L3IccSVZ1ulaB+TjsnFK+9dkyAMqV/YBwlFRErIyCwwNXGnUijQlIUCwJg60u7yjz9E8 xS7Q== 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=7EMsyztakmfRRe2zr23yF2ft/z26d8HOGVOVvypa0C4Dq8QhD2SYIK6tT69rLjMGN4 ZkHhCeMQZ/IVrcO4Xz1hJYdobO3vKpFT1FMYk5x18IqUhWQo7y8ZRVvmkNGcjgD47ts9 BZy5UqWdASpXXTa1+5jFjumuSUEkZHQoaVCdaE9i8UJUR7/P7TE/Vgm2ZDPHO7j/AT/x ZNmb2CaARC4stxeOY8wgt5uSKZHASGJra9mD7BqpSDdGmy75tGjtOuppYq1guBA+8ZuR jhKHEr66OT/zv0u6crgYtpQXn8sZtT0zT+XkIXgazPK8TupnzorB8sqc5QaDpB5W4KIz DC8g== X-Gm-Message-State: ACrzQf3RVbqEA+W05gbsA6J3sSkEQrDaclWs8pkl9XhyEV85OU/ktDV+ eTAIZ5x5v06+GshQ2YNjMXE= X-Received: by 2002:ac2:5321:0:b0:4a4:3c25:dbd with SMTP id f1-20020ac25321000000b004a43c250dbdmr5837748lfh.406.1666332056154; Thu, 20 Oct 2022 23:00:56 -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 p6-20020ac246c6000000b0049e9122bd0esm3021950lfo.114.2022.10.20.23.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 23:00:55 -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 V2 1/2] dt-bindings: mtd: partitions: support marking rootfs partition Date: Fri, 21 Oct 2022 08:00:50 +0200 Message-Id: <20221021060051.2508-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?1747276027981537093?= X-GMAIL-MSGID: =?utf-8?q?1747276027981537093?= 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 --- 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 Fri Oct 21 06:00:51 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: 6519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp510506wrr; Thu, 20 Oct 2022 23:04:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kiBd9eHHbLJ60EWCsnEpSSB1NlclVGleq6Vj5IaVZThsyRl6+O7yigNwwwu27oSqeRpeY X-Received: by 2002:a17:906:4fcd:b0:78d:8059:17c with SMTP id i13-20020a1709064fcd00b0078d8059017cmr14435730ejw.423.1666332272655; Thu, 20 Oct 2022 23:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666332272; cv=none; d=google.com; s=arc-20160816; b=PhZ7HTrg/D1dFhsUeCopYVjf27Ek2s9ULci45pZ347vqlb4B+3ftW56655IRZOTZ9R IgWYajIPfcgYfoEUBY9KfSA3VXgA6xrsw3b3DiG00J61MS2sj5nhft9VgfQW9q4R/ubD 5XVUbsPh20F4w+WRF7mI+nYK0Os3uIEKVDewRJZNKcaK2z+RFyR/z8I9SwNts1PB/Txl 4RVZYgid8zrdeCMdSGPnPpCL0zgO1Pq5RvwT7BCSX7HP5mdjElpy7spc8QAo2GCUGExR WV+lUCdwdEGP7zedYotp1d/jJggtAXMrIrvVFs5sRnKtH2BYyGfI5Xx5z3cK5iPmca71 hMow== 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=RJ9xIMP9KJSnyP3kmEcAZFEOTKsj48z0+6bhrdbyYmQ=; b=VfjyZ9j/d7cvKjWQV187+yBeuU1eXKC5YiHjFvB//x0OtjR4BabpSiC687x1dWBcoO 40JFjMp6Dxi5BLigr0vxfZuYqoaNhxfwRHn2FNXIFOq688uB+igP3wDvOa3sw/LPQ72D RkQ0Gj4EMuTXXvUCTZ8U/GXg3i3/St3jEjSmyxPnk/AMYr5xI+H+iZSIn+Bzl1UL7TGc GieJqTKXp0uDiCqvFaxwtJcAe3LGsAAG0NA/gmOzGmiq1vmk8MLmv7Vckn9+15BrO6pQ dOtlIm0MRrctnlLY4ETWPfmK5FkCXF5/2BIGzdYpw+6t9fwCEhqoCP70NTc+ujjQaWML v3Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d1Ic9JTy; 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 mp14-20020a1709071b0e00b0078198611a45si18241546ejc.980.2022.10.20.23.04.08; Thu, 20 Oct 2022 23:04:32 -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=d1Ic9JTy; 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 S229782AbiJUGBF (ORCPT + 99 others); Fri, 21 Oct 2022 02:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbiJUGBC (ORCPT ); Fri, 21 Oct 2022 02:01:02 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D17C1D3A47; Thu, 20 Oct 2022 23:01:00 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id f37so3290211lfv.8; Thu, 20 Oct 2022 23:01:00 -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=RJ9xIMP9KJSnyP3kmEcAZFEOTKsj48z0+6bhrdbyYmQ=; b=d1Ic9JTyYswqZsEL5SydOKhL435NQPu3xf45ckQx+lh0zbljdQXq32zSHLZSdZhfGK 0NTAOfVvX/A9wGkQREP8rf4nIZ2eIZ5dknqfY6MXMR5wSF0tSbL4i443zXJDCpCu3dM9 LLnBbM0HkC7bE2lEC8Iy4RpSsR3VM4UbZ+Zpsx8RVHF/cPNO94o8MVbVdBkF3vhnNQwW mlkB2aOzr2RpA5I+GZX0sodWgJkknZuegcQYzVXIU+R998qS1zhMaoGJPt1ym+bJXFnj Rx7DyriZhROpSd0A7uzEvPKl8bRHVk8I3Jy7cM6KPFBLtnciJLQ99aHoQQTYutgufa8r Qpzg== 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=RJ9xIMP9KJSnyP3kmEcAZFEOTKsj48z0+6bhrdbyYmQ=; b=MUsJUVCW01sjDCRqvw0m4Ke85r6wgPvakkMyPDVpv/VPvAHV65Q1oWQjBfbVuPSC1U 1lu4b01IRmw46vaNAhkcg4FgM8xGR4SPtVRDHt7O8UfFnskAcgRLfOyx152aDhbCILZ5 wSgURWSUPLHNe3ZKnP0iXVmtObF3T5L4MpWLUdFqSz4q2VnsS5Tkt5rxVzxR/gJBtaeE V6fPc9w96e52B2zXwmEDqgTq+eBHPP2vMD9BHDO/+fx4f6ep0sd6bMY5PGWJHtk1tH0J ODRU7kbag79j74AH12HAdg2NxZZGAxGpEHlJrlYHtZ38Hmo+SsMtxBhVvMykRkyy5nYt MKtA== X-Gm-Message-State: ACrzQf0TlujcIFkOhAGz6SJh5nPNylQgLSBNRKvdIh0z0yAsqwtzx0ln ymcnC5rb8S5i1mIx5BBLkzg= X-Received: by 2002:a05:6512:11e9:b0:49f:d530:9f25 with SMTP id p9-20020a05651211e900b0049fd5309f25mr6513590lfs.533.1666332058608; Thu, 20 Oct 2022 23:00:58 -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 p6-20020ac246c6000000b0049e9122bd0esm3021950lfo.114.2022.10.20.23.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 23:00:58 -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 V2 2/2] mtd: core: set ROOT_DEV for partitions marked as rootfs in DT Date: Fri, 21 Oct 2022 08:00:51 +0200 Message-Id: <20221021060051.2508-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021060051.2508-1-zajec5@gmail.com> References: <20221021060051.2508-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?1747276029253326225?= X-GMAIL-MSGID: =?utf-8?q?1747276029253326225?= 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. --- drivers/mtd/mtdcore.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 07249af4f890..034b06aff660 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -735,6 +736,12 @@ 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)) { + pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name); + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index); + } + /* 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