From patchwork Tue May 2 16:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 8845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp777325vqo; Tue, 2 May 2023 10:20:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QJYPnjtMMe0aywN+WC/nfsY8AWFcFRaoKVdyjc67KK6BdTtcmPfPg5+fWcIywzGbknj+Z X-Received: by 2002:a05:6a20:1604:b0:f6:5a75:7d44 with SMTP id l4-20020a056a20160400b000f65a757d44mr4761136pzj.12.1683048042370; Tue, 02 May 2023 10:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683048042; cv=none; d=google.com; s=arc-20160816; b=kZp3hn25UMLYY/nK0UCIwS9wv1rDXbZG2bCaYlBI91c9We58dH7g2qj0mSQY4Rney6 nfWZ3DkucGiowRE+KWEwl8hFIZ33jIH32lMIGwfdlisD6f+GkHT37f8t2j0b2Qw7jxSO MYTx5NElykLOSh0R1elX/Wo8htvvLWiQuvNrYmNkR000bb5BIk6wSyRQGeb6dIZPyjjQ hm3GVNgOa2tSPQuRAH4MrKrsPFSSHHcAe/Hd7Zqcwlqpwo9mriPxISPqIBvlgFyuwnmQ MXuN7XxJcIG35ge7U6Iyf7x1nt8JOfIqpUOFhLq2ioOiQKlh0uYCFI7dcah08M5i1SdF QXMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=cJfaZQG8hBrJtDhajAlvORrz26NEG9fDeDDmZDb2uKw=; b=QrPdqwcI+xdrSCOVQ4dBxQ3ypNQfXTWbpPG441ZSaZNIIIG83yPfl7wc9gTmaGm6O1 WzRfmaIBur1RlT44BAd19ASc8Zp1hmKThoO7/ize5mYOozOe2FJeTj9xjjs8BjRuaI3K Jv0XbuSD9fjou0i6ZdsSOVpnpLB/6TtYtJREoGtNyppuqqRanOX4qd6MknkZ8wR5pT3K BCyeaIDPZtQmSiCGpCgLwMPxVPIgQJAleEis2rBz5VSuH4d2NWu+caNO+ZiOuswIbooM if5KFXyqsTjyPZdeOz3KV7gZ6CHBgEQwqm+I52YxWZG4p9Wya5jYEQh2YOUNK1HFLBDb pN2w== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020aa79984000000b0063b8982c669si30534580pfh.317.2023.05.02.10.20.29; Tue, 02 May 2023 10:20:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234292AbjEBQsN (ORCPT + 99 others); Tue, 2 May 2023 12:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233724AbjEBQsL (ORCPT ); Tue, 2 May 2023 12:48:11 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8CD1992; Tue, 2 May 2023 09:48:09 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pttAS-0000UL-0r; Tue, 02 May 2023 18:47:56 +0200 Date: Tue, 2 May 2023 17:47:48 +0100 From: Daniel Golle To: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Zhihao Cheng , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 0/4] mtd: ubi: behave like a good MTD citizen Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1764803783825900208?= X-GMAIL-MSGID: =?utf-8?q?1764803783825900208?= As of now one can easily trigger the existence of "ghost" UBI devices or even worse by removing e.g. the SPI bus driver which previously provided access to an SPI-NAND chip. Make UBI behave more like other MTD users and create/remove UBI devices based on MTD notifications. As removing could previously fail in case of an ubiblock device still being in use, make sure there are no excuses preventing release of an already gone MTD partition. This makes it possible to attach UBI devices immediately after the MTD partition becomes available, which will allow using UBI volumes as nvmem-cells provider in the future [1]. Introduce new device tree compatible "linux,ubi" to be used on MTD partitions which should be attached. In order to make sure ubiblock devices are still created according to the module or kernel parameters, let ubiblock creation from parameters be triggered by UBI_VOLUME_ADDED notifications instead of trying only once during boot. [1]: https://forum.openwrt.org/t/asus-tuf-ax4200-support/155738/44?u=daniel Daniel Golle (4): mtd: ubi: block: don't return on error when removing mtd: ubi: block: use notifier to create ubiblock from parameter dt-bindings: mtd: partitions: add linux,ubi mtd: ubi: attach MTD partition from device-tree .../bindings/mtd/partitions/ubi.yaml | 49 +++++ drivers/mtd/ubi/block.c | 158 ++++++++------- drivers/mtd/ubi/build.c | 189 ++++++++++++------ drivers/mtd/ubi/cdev.c | 4 +- drivers/mtd/ubi/ubi.h | 6 +- 5 files changed, 271 insertions(+), 135 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/ubi.yaml base-commit: b5fda08ef213352ac2df7447611eb4d383cce929