From patchwork Wed Oct 19 11:48:54 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: 5341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp294348wrs; Wed, 19 Oct 2022 05:23:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5zvldrOwjJ3hYQEFrsGwpygIdWVTX4ezhXjYr0q2KhIy1VoC3rI1tBPZ6pwSd5wSS0M8uP X-Received: by 2002:a17:906:8a79:b0:78d:9c52:2196 with SMTP id hy25-20020a1709068a7900b0078d9c522196mr6633608ejc.328.1666182238207; Wed, 19 Oct 2022 05:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666182238; cv=none; d=google.com; s=arc-20160816; b=wK4PjBIwKYpI34svDC+ySE4yipcCtrntnz81tZbxW3KvswIsQIk8igbfR2Y3Yuj7wb Ac7dVkQF10B8Kg5Zz10hrRKDZJOH3d0wF2xxYM32RtKTcaRKvP0OsDu0ohZKXWtz531a 7Qya2n52jC6pm0PYj5U6iFrQybOmjBc8DD5+/BGMq/0WPpCdGMdNUM5Z42+KXaeztUyg MkHbhAC2aYCN26sCgfEMrWiQhC5Rvcnngl1f+L3X7VOVY4TXgki7tKOEbjAHVB0AVUeW q74tX/OZf2ZnIzgzvAs2bbgeaVlc4PQanReMBONz7i3narm3vaBvJKbzOoiuC9NZcpf/ hxBg== 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=/SgthmTOzp3GGabfMw1BGo5g3o2HNTfweNMsL53GOTc=; b=HrNi/1KH1CGAWTmFUuiDIdYNZm51m7VWrZNh693yNtby9ruuTjMyJF6mAEWQKEegwz V8EFSllzushm1ZoBsyHpGLokJfVB+LIKrmeBABwif3EkMxjimt3xr2dMOIiM9JfPAUd6 90L76RYYGeOoS6KQ137PQJtFQzU3Hxe2RsmWW/Lc5LZd6G2xK3XFCwxY/oLcJg5+248y U+/hyCO49FTgdmQZCvfsff5J2YEukiiQWnjLevaupryHKBEdpPHdJ8NQX45KEvC+PNaO v9onH3KgTb5LVmOQYjQCE3m/TzCfaLacoU6HA7L/XTO5S4rmm+HQca9PbexjGbvO8ocS vNZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XznED3sZ; 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 p19-20020a05640210d300b00451d5c11293si11999968edu.496.2022.10.19.05.23.32; Wed, 19 Oct 2022 05:23:58 -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=XznED3sZ; 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 S232764AbiJSMOo (ORCPT + 99 others); Wed, 19 Oct 2022 08:14:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233121AbiJSMOR (ORCPT ); Wed, 19 Oct 2022 08:14:17 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D81B0183D8A; Wed, 19 Oct 2022 04:50:43 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id bp11so28694499wrb.9; Wed, 19 Oct 2022 04:50:43 -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=/SgthmTOzp3GGabfMw1BGo5g3o2HNTfweNMsL53GOTc=; b=XznED3sZp9svoyHkLA1j5DhdbO8l+nPvuyUqWZcMwP52T0KIuuQWMrZIz7p9JrYekv sUzIoYPZXBgeqkGX7wYNW9wgLVaWBTZMMYETm/qxREwkGqRI+pg2cmwkNFAvyPUa4PjM xpX/x3WKxWVoKPUEV1KEJdoOszoC69e8Afbn7Aum9e0FJYhz9MemAWhhWWqOF/VgTZPc qSljtj7HUICXFDKR3YXI7ogC7F3bOK7tCOJ8hq1PgYVSkj/nwVVZAZ4Lja3RcToN9U2I eVk/3TWf1bfoMCH67WoNWUvOUyDNPjg0YWCWBwJtm/jGVl7GVSRdg5qrHZRwLblO+iy8 FeXw== 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=/SgthmTOzp3GGabfMw1BGo5g3o2HNTfweNMsL53GOTc=; b=6SojIR0Txdogg/jNT0iX8FsNtnoWf6Xd6N+u3hiHfPPCjJfEU7oLUHs5QdT4WsS/Xf cVIuNeGAfKtVPKOk9d4zpV2pz62spE8SuCb9JQUGcBBFkhv3N+ylvDcKBO/tgrNuuSHY NdP+RAHWhtBOQTiRkSU8MeiflPjKBwIY97UNkQPXdZz4TAvgVTIc4BjZ9gOn4D9ZFK/J 6tViWhKgz96CPtqHnvkviT6nvVjEsKsQl8hQq5fXeaEpVlKrZ+NuZWo5BONOa+1zRErV L9+gRUZBzxJwMgdHqtMPcGl9b5wcyr4MnfMDNtazP9RFXPQ54A7Xc4Lw48fDG3o6P8FA MxQw== X-Gm-Message-State: ACrzQf1tyQphHATxI1ImyrjZAQa7qSx1NfHkaWqpLhT5z0m5ppNzclBu oAMXEN52HeSzB7OPT+6EJloHqJ/m5Rg= X-Received: by 2002:a17:906:eec9:b0:73d:c369:690f with SMTP id wu9-20020a170906eec900b0073dc369690fmr6449809ejb.767.1666180173514; Wed, 19 Oct 2022 04:49:33 -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 fg4-20020a056402548400b0045bef7cf489sm10186308edb.89.2022.10.19.04.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 04:49:32 -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 1/2] dt-bindings: mtd: partitions: support marking root device partition Date: Wed, 19 Oct 2022 13:48:54 +0200 Message-Id: <20221019114855.31639-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?1747118706158642707?= X-GMAIL-MSGID: =?utf-8?q?1747118706158642707?= 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,root-device" property to mark correct flash partition. Signed-off-by: Rafał Miłecki --- .../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..e627085df4fc 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,root-device; }; }; diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml index f1a02d840b12..671906acf1bd 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,root-device: + description: Marks partition that is a root device with filesystem to mount + and boot user space from + if: not: required: [ reg ] From patchwork Wed Oct 19 11:50:41 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: 5343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp295376wrs; Wed, 19 Oct 2022 05:25:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4YmcmYXKFSP9b2jixzRo6V5VlU7WpT7QVOQfZ3pP67/nMaCe3FYCd+JHm6HZVKdJYWVwqn X-Received: by 2002:a17:90b:3804:b0:20d:4e77:373a with SMTP id mq4-20020a17090b380400b0020d4e77373amr45318603pjb.212.1666182341625; Wed, 19 Oct 2022 05:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666182341; cv=none; d=google.com; s=arc-20160816; b=JNMYiyEQtnAO5eScRgKVrHVg+7Ld8fm0M5hyzZpQGTiK+CqRxI+KURx1d+ipCFseNR nhJN4dXF4RDM7Y6tGxifzzWbPc965YA8KduiXJ/WwoqiR3spojJyJMiWGRmTqewCkv8o uUpwxyRT5JVfhGsVF9JBC3HkBPk1ndPsZfbFqbt/6DP+M2m2FvxVVm7MfUi2MSGvoEIH kxRHTZkc5IiIEmAuy5y08lg9tlzgWh44NNujb0bpTYFEYCAawWK0FTdiWO154Rh/BjEr X3Lwt2Vvl87pJw4z0DdFb4gKlxLggJC1OKsdJRSy7iEv+/ot4yTopHqNgAiXDivDWEaT Jn3w== 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=yTGwtjY7Qx3UHK834yfCMHLL0TaAs+yVt4csz4H7rFw=; b=GLT3cA+FvTrHSDvnxbj0Fy1sXzvK32LROoknS7w/sIWv/eIDa7qo3WtfeT7kENi9T4 6c2QEvIeUZvxy8fcXKH/b4HI0BRHyMXq/3xMJFtZICGd6p38Qvx6PE58QL8xb++uWLVg 27b0570zuMaheIaBPWsTnaMH3P3e43qk2qCTi+LLh1jxn40ttQt1YW/RaMgoZZhJssM0 REyV4kLI56NmvjVHUI3nSF7WWcv4GthCHit2QcTbygjK3ADepWmH9XDJluYxFT3XCEwL njA+iCREXu8oqwIHgIwkqzCrbemCXemgfF/5bwVimU9e9vETwVksVawh9ujh6rZ6MNtr VAwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OtokJ3G5; 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 q14-20020a056a0002ae00b00565e7a78039si16054335pfs.249.2022.10.19.05.25.24; Wed, 19 Oct 2022 05:25:41 -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=OtokJ3G5; 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 S232907AbiJSMQ0 (ORCPT + 99 others); Wed, 19 Oct 2022 08:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232842AbiJSMPz (ORCPT ); Wed, 19 Oct 2022 08:15:55 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C73B22B0E; Wed, 19 Oct 2022 04:51:56 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id m15so24819436edb.13; Wed, 19 Oct 2022 04:51:56 -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=yTGwtjY7Qx3UHK834yfCMHLL0TaAs+yVt4csz4H7rFw=; b=OtokJ3G5ZiLF/OC4iEJMusA6NeuqVEVdAZ9v0gKZ8M5SVAINXZqwJnLLxNhUZUgn8R Q7gUdiErZk0QhUbU84FHgDdN+NzKzliyYGENPzQm0dU8dRuZrN4SxXvFchaXy4nCYdz+ 9m8rfs2Wr8KKCpoURG3k9LjtOE1djHUFfUWmOGsjHt90WSAMwlXlepZVemcfXbkZV882 j1JEIpQJk7vhe8E/4jkP7JzjmN5G4sHQ+WWbRkhH6rjTLvP+rBW440/lpRqjboaxwzsm 78L82AZScEuO4G8Pu7+oje4nyPKYFi1KhoQQibGXkee3QvlrxpWsuo1+dkPwB0MXStJt 3blA== 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=yTGwtjY7Qx3UHK834yfCMHLL0TaAs+yVt4csz4H7rFw=; b=mR05cQJSKmBYtbYk/RCBD8IXOBoXa7qBk3SJU7OUNTA+3jvvLS+RxweIiulI52k/KL 02QDNe5oHalHaQMDbXzKEbA+TlIrv6ZZaOZdo0wOjhtH+64szR5THzR1gBkCZv28bLXo 7TfBYB1hSMM+NRntN9mUmIEP+t7Nn79Ld+T+DSB0wgeb1Fg/7cM5bPIf9xLjiSnO63Oi h+61yxQTDzYThRygXq2wrsCL5qG7nu1azqZt6IirVx8JbjJm8Ut1AmpjdI/t0DkhQEGy tH/9zJaeXEb/nyKv4PHN3fa1uokRgF/KnvCtgIXMVpp9505RAVFt3xYu03TxGvD2YCMp zpGQ== X-Gm-Message-State: ACrzQf1FoPZ47+InYEoI+sihES/XmvxDvwCH4VMG3cG6d1CfcF+4mOox juj6j6q7jVYPZCP0w73WXPk= X-Received: by 2002:a05:6402:3709:b0:459:279e:fdc6 with SMTP id ek9-20020a056402370900b00459279efdc6mr7180563edb.338.1666180247042; Wed, 19 Oct 2022 04:50:47 -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 dk24-20020a0564021d9800b0045b910b0542sm10377884edb.15.2022.10.19.04.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 04:50:46 -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 2/2] mtd: core: set ROOT_DEV for partitions marked as root devices in DT Date: Wed, 19 Oct 2022 13:50:41 +0200 Message-Id: <20221019115041.31805-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019114855.31639-1-zajec5@gmail.com> References: <20221019114855.31639-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?1747118814641556125?= X-GMAIL-MSGID: =?utf-8?q?1747118814641556125?= From: Rafał Miłecki This adds support for "linux,root-device" binding that is used to mark root device MTD partition. It's useful for devices using device tree that don't have bootloader passing root info in cmdline. Signed-off-by: Rafał Miłecki --- 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