Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1877712/?format=api
{ "id": 1877712, "url": "http://patchwork.ozlabs.org/api/patches/1877712/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/patch/380712c15c1e958ed0b6af33ec551eaaa66e7abd.1702952891.git.daniel@makrotopia.org/", "project": { "id": 3, "url": "http://patchwork.ozlabs.org/api/projects/3/?format=api", "name": "Linux MTD development", "link_name": "linux-mtd", "list_id": "linux-mtd.lists.infradead.org", "list_email": "linux-mtd@lists.infradead.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<380712c15c1e958ed0b6af33ec551eaaa66e7abd.1702952891.git.daniel@makrotopia.org>", "list_archive_url": null, "date": "2023-12-19T02:33:14", "name": "[v7,4/7] mtd: ubi: attach from device tree", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d6a5d6594bfa83dc4026f9861cae6ed8d802b28a", "submitter": { "id": 64091, "url": "http://patchwork.ozlabs.org/api/people/64091/?format=api", "name": "Daniel Golle", "email": "daniel@makrotopia.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-mtd/patch/380712c15c1e958ed0b6af33ec551eaaa66e7abd.1702952891.git.daniel@makrotopia.org/mbox/", "series": [ { "id": 387243, "url": "http://patchwork.ozlabs.org/api/series/387243/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/list/?series=387243", "date": "2023-12-19T02:32:00", "name": "mtd: ubi: allow UBI volumes to provide NVMEM", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/387243/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1877712/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1877712/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=b15B9QY3;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4SvLP85tjMz20H4\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 19 Dec 2023 13:34:20 +1100 (AEDT)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux))\n\tid 1rFPvC-00Cb1H-0O;\n\tTue, 19 Dec 2023 02:33:26 +0000", "from pidgin.makrotopia.org ([185.142.180.65])\n\tby bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux))\n\tid 1rFPv8-00Caym-1j\n\tfor linux-mtd@lists.infradead.org;\n\tTue, 19 Dec 2023 02:33:25 +0000", "from local\n\tby pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256)\n\t (Exim 4.96.2)\n\t(envelope-from <daniel@makrotopia.org>)\n\tid 1rFPv2-0008JA-1H;\n\tTue, 19 Dec 2023 02:33:17 +0000" ], "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Cc:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=+W56qlU4agjyAs+BGlpvTKKHPM1Uj2TrxZB2cYMiMF0=; b=b15B9QY33ewJwh\n\t+oSUd3E/CztD5nJ4OJH+KsRcTneOrMZDnnAKTqEyaa2KKO+nvG9FGvUGd5ehaLqLtnBBEVl8bhw6r\n\tRbjAfdfprVu0bvP61t9vhQlfZpq2uwVHWuooLX7wKVTPrZtlV3TK5o8au6+TI8O8+M0gUAXeiXxKY\n\tsMdfsdFavpUs/oYglRiOwHnCEWh3htltLkbMRr8SAuhKGrViXrummTD+LPRjvL//zyTCVu8s59wNb\n\t5FXBNkpIRomIi5e1rGUMwmqIQM/8hUOaCeyCuyh9Z3G171o+kV8UzD8iQHBmFBuBWi9NUeEdRTBzd\n\tXtuIxJW6xYcoKu3dKUkA==;", "Date": "Tue, 19 Dec 2023 02:33:14 +0000", "From": "Daniel Golle <daniel@makrotopia.org>", "To": "Miquel Raynal <miquel.raynal@bootlin.com>,\n\tRichard Weinberger <richard@nod.at>,\n\tVignesh Raghavendra <vigneshr@ti.com>,\n\tRob Herring <robh+dt@kernel.org>,\n\tKrzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,\n\tConor Dooley <conor+dt@kernel.org>,\n\tDaniel Golle <daniel@makrotopia.org>, linux-mtd@lists.infradead.org,\n\tdevicetree@vger.kernel.org, linux-kernel@vger.kernel.org", "Subject": "[PATCH v7 4/7] mtd: ubi: attach from device tree", "Message-ID": "\n <380712c15c1e958ed0b6af33ec551eaaa66e7abd.1702952891.git.daniel@makrotopia.org>", "References": "<cover.1702952891.git.daniel@makrotopia.org>", "MIME-Version": "1.0", "Content-Disposition": "inline", "In-Reply-To": "<cover.1702952891.git.daniel@makrotopia.org>", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20231218_183322_581974_D286F3C5 ", "X-CRM114-Status": "GOOD ( 22.85 )", "X-Spam-Score": "0.0 (/)", "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam. The original\n message has been attached to this so you can view it or label\n similar future email. If you have any questions, see\n the administrator of that system for details.\n Content preview: Introduce device tree compatible 'linux,ubi' and attach\n compatible\n MTD devices using the MTD add notifier. This is needed for a UBI device to\n be available early at boot (and not only after late_initca [...]\n Content analysis details: (0.0 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -0.0 SPF_PASS SPF: sender matches SPF record\n 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record", "X-BeenThere": "linux-mtd@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/linux-mtd/>", "List-Post": "<mailto:linux-mtd@lists.infradead.org>", "List-Help": "<mailto:linux-mtd-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>", "Errors-To": "linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "Introduce device tree compatible 'linux,ubi' and attach compatible MTD\ndevices using the MTD add notifier. This is needed for a UBI device to\nbe available early at boot (and not only after late_initcall), so\nvolumes on them can be used eg. as NVMEM providers for other drivers.\n\nSigned-off-by: Daniel Golle <daniel@makrotopia.org>\n---\n drivers/mtd/ubi/build.c | 135 ++++++++++++++++++++++++++++------------\n 1 file changed, 96 insertions(+), 39 deletions(-)", "diff": "diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c\nindex 7d4ff1193db6f..8c3f763e4ddb8 100644\n--- a/drivers/mtd/ubi/build.c\n+++ b/drivers/mtd/ubi/build.c\n@@ -27,6 +27,7 @@\n #include <linux/log2.h>\n #include <linux/kthread.h>\n #include <linux/kernel.h>\n+#include <linux/of.h>\n #include <linux/slab.h>\n #include <linux/major.h>\n #include \"ubi.h\"\n@@ -1219,43 +1220,43 @@ static struct mtd_info * __init open_mtd_device(const char *mtd_dev)\n \treturn mtd;\n }\n \n-static int __init ubi_init(void)\n+static void ubi_notify_add(struct mtd_info *mtd)\n {\n-\tint err, i, k;\n+\tstruct device_node *np = mtd_get_of_node(mtd);\n+\tint err;\n \n-\t/* Ensure that EC and VID headers have correct size */\n-\tBUILD_BUG_ON(sizeof(struct ubi_ec_hdr) != 64);\n-\tBUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64);\n+\tif (!of_device_is_compatible(np, \"linux,ubi\"))\n+\t\treturn;\n \n-\tif (mtd_devs > UBI_MAX_DEVICES) {\n-\t\tpr_err(\"UBI error: too many MTD devices, maximum is %d\\n\",\n-\t\t UBI_MAX_DEVICES);\n-\t\treturn -EINVAL;\n-\t}\n+\t/*\n+\t * we are already holding &mtd_table_mutex, but still need\n+\t * to bump refcount\n+\t */\n+\terr = __get_mtd_device(mtd);\n+\tif (err)\n+\t\treturn;\n \n-\t/* Create base sysfs directory and sysfs files */\n-\terr = class_register(&ubi_class);\n+\t/* called while holding mtd_table_mutex */\n+\tmutex_lock_nested(&ubi_devices_mutex, SINGLE_DEPTH_NESTING);\n+\terr = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0, false, false);\n+\tmutex_unlock(&ubi_devices_mutex);\n \tif (err < 0)\n-\t\treturn err;\n-\n-\terr = misc_register(&ubi_ctrl_cdev);\n-\tif (err) {\n-\t\tpr_err(\"UBI error: cannot register device\\n\");\n-\t\tgoto out;\n-\t}\n+\t\t__put_mtd_device(mtd);\n+}\n \n-\tubi_wl_entry_slab = kmem_cache_create(\"ubi_wl_entry_slab\",\n-\t\t\t\t\t sizeof(struct ubi_wl_entry),\n-\t\t\t\t\t 0, 0, NULL);\n-\tif (!ubi_wl_entry_slab) {\n-\t\terr = -ENOMEM;\n-\t\tgoto out_dev_unreg;\n-\t}\n+static void ubi_notify_remove(struct mtd_info *mtd)\n+{\n+\t/* do nothing for now */\n+}\n \n-\terr = ubi_debugfs_init();\n-\tif (err)\n-\t\tgoto out_slab;\n+static struct mtd_notifier ubi_mtd_notifier = {\n+\t.add = ubi_notify_add,\n+\t.remove = ubi_notify_remove,\n+};\n \n+static int __init ubi_init_attach(void)\n+{\n+\tint err, i, k;\n \n \t/* Attach MTD devices */\n \tfor (i = 0; i < mtd_devs; i++) {\n@@ -1304,25 +1305,79 @@ static int __init ubi_init(void)\n \t\t}\n \t}\n \n+\treturn 0;\n+\n+out_detach:\n+\tfor (k = 0; k < i; k++)\n+\t\tif (ubi_devices[k]) {\n+\t\t\tmutex_lock(&ubi_devices_mutex);\n+\t\t\tubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1);\n+\t\t\tmutex_unlock(&ubi_devices_mutex);\n+\t\t}\n+\treturn err;\n+}\n+#ifndef CONFIG_MTD_UBI_MODULE\n+late_initcall(ubi_init_attach);\n+#endif\n+\n+static int __init ubi_init(void)\n+{\n+\tint err;\n+\n+\t/* Ensure that EC and VID headers have correct size */\n+\tBUILD_BUG_ON(sizeof(struct ubi_ec_hdr) != 64);\n+\tBUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64);\n+\n+\tif (mtd_devs > UBI_MAX_DEVICES) {\n+\t\tpr_err(\"UBI error: too many MTD devices, maximum is %d\\n\",\n+\t\t UBI_MAX_DEVICES);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Create base sysfs directory and sysfs files */\n+\terr = class_register(&ubi_class);\n+\tif (err < 0)\n+\t\treturn err;\n+\n+\terr = misc_register(&ubi_ctrl_cdev);\n+\tif (err) {\n+\t\tpr_err(\"UBI error: cannot register device\\n\");\n+\t\tgoto out;\n+\t}\n+\n+\tubi_wl_entry_slab = kmem_cache_create(\"ubi_wl_entry_slab\",\n+\t\t\t\t\t sizeof(struct ubi_wl_entry),\n+\t\t\t\t\t 0, 0, NULL);\n+\tif (!ubi_wl_entry_slab) {\n+\t\terr = -ENOMEM;\n+\t\tgoto out_dev_unreg;\n+\t}\n+\n+\terr = ubi_debugfs_init();\n+\tif (err)\n+\t\tgoto out_slab;\n+\n \terr = ubiblock_init();\n \tif (err) {\n \t\tpr_err(\"UBI error: block: cannot initialize, error %d\\n\", err);\n \n \t\t/* See comment above re-ubi_is_module(). */\n \t\tif (ubi_is_module())\n-\t\t\tgoto out_detach;\n+\t\t\tgoto out_slab;\n+\t}\n+\n+\tregister_mtd_user(&ubi_mtd_notifier);\n+\n+\tif (ubi_is_module()) {\n+\t\terr = ubi_init_attach();\n+\t\tif (err)\n+\t\t\tgoto out_mtd_notifier;\n \t}\n \n \treturn 0;\n \n-out_detach:\n-\tfor (k = 0; k < i; k++)\n-\t\tif (ubi_devices[k]) {\n-\t\t\tmutex_lock(&ubi_devices_mutex);\n-\t\t\tubi_detach_mtd_dev(ubi_devices[k]->ubi_num, 1);\n-\t\t\tmutex_unlock(&ubi_devices_mutex);\n-\t\t}\n-\tubi_debugfs_exit();\n+out_mtd_notifier:\n+\tunregister_mtd_user(&ubi_mtd_notifier);\n out_slab:\n \tkmem_cache_destroy(ubi_wl_entry_slab);\n out_dev_unreg:\n@@ -1332,13 +1387,15 @@ static int __init ubi_init(void)\n \tpr_err(\"UBI error: cannot initialize UBI, error %d\\n\", err);\n \treturn err;\n }\n-late_initcall(ubi_init);\n+device_initcall(ubi_init);\n+\n \n static void __exit ubi_exit(void)\n {\n \tint i;\n \n \tubiblock_exit();\n+\tunregister_mtd_user(&ubi_mtd_notifier);\n \n \tfor (i = 0; i < UBI_MAX_DEVICES; i++)\n \t\tif (ubi_devices[i]) {\n", "prefixes": [ "v7", "4/7" ] }