From patchwork Wed Sep 25 21:45:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13812445 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FA62155733; Wed, 25 Sep 2024 21:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300804; cv=none; b=JopIF5jdQ2CGrCQR17O3706Yz26fuSfe3tS00qfljSrRQoJAK8JL9LZKeO9n3jaQgFvJYg77uANw+TxS5NJw8AyeVVsd/71dqTX3Uf3tZ1ltI8JJ15tqEqGdxID1/8hmCX2YSdA55F7kY+u8liEiE3HXWUtfxNrodu+ZuR9XIKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300804; c=relaxed/simple; bh=vIZUmOhkctrpxNjE/bq31Se+xRGgI8VKyz9uNEv0GsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FeJITD+oFK/npaSCwqtudPtO+OeaCGPWdBIH3mAWH+mZsIELftO5N5LHPF6liD3ZL3MOtQRa9WPfMoh4bdXCWi11dEMSFgzh946hlS6PIHXUL5QIg5Y0MhZRgmSjJDJS9bHZVsqnVecGvO306PqF3tLiK2jNATHW/UCgrRrbUOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jen2M9UI; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jen2M9UI" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42cba6cdf32so2336675e9.1; Wed, 25 Sep 2024 14:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727300801; x=1727905601; darn=vger.kernel.org; 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=4T9c6jNuxQUPP/Rbzo55YkzEPcrdsPIICvkg9bn4/tM=; b=jen2M9UIvNnpuNnpADilgCuXxN91dsPXb0y1OBOAXBcdXNrbOEaNoxH9dHZTPqnW2P /UcBhRYSVD2W8CrrTOyoEy7Hu42y/Y2aJ3kdsWt9jy9quMU+4PzPLl7i/h1M7MweznAm 7rOmpMFpgF22QStPELnXxE9jm7l892MzswpgvEgLULE57TM8h9YRsNO8bpPZ8XxsxGkQ mOtYKjNDQJMjg1qG4FZqJj0FE16pz08ct082r0tx2vTUs+FE+6ojGNAmKpUryWj798u5 B2+8rcK6eq71FvqaRp26KRFJspPNAW/1ncsK+b9EFDPK3RHzQYRnglMOotNlsrc/fSK8 TwcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727300801; x=1727905601; 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=4T9c6jNuxQUPP/Rbzo55YkzEPcrdsPIICvkg9bn4/tM=; b=Whf8o5bATHnzWh+jYkYjOTrs90Guj3AKJZnByJMbU1Zu7QNWWg9DJ4k889UR8TE99g qsAdqtfCuQtzLRbeiqfCHIBAE8ZylnqiE2j4FA/xqEs3S2WQzwnefBQvKlmsv1mCJnvn kkBiH+3j9KHoNfTRv/rAntGxg+BX7UFGIQKGIh1EVBSYo50RlIJV7bztkRrIgfSgcQip Ihh5WbX97DhFeQeUzX6eCdHFoeYZiQKRUzvFuXPHXJb4rUCY6eB3sHIamc06lOC6NDJw kkvRD1ZLzRpgqT107pwEts0is6EKR9eSgAFjSiWhxiike3ArOA5cOQFBlVROxUDempJt IDhg== X-Forwarded-Encrypted: i=1; AJvYcCUFq+kxRifTaihgr/LCEcWFO4+7FWnvw1pAGLqzk5q9uJJpbZtRJPsIfPlJ4uzIpMr6P1YqTv2HrvA1@vger.kernel.org, AJvYcCUrHEhUPNseaq9pEtUAG/4fNaEbTtE2oBc+ByqH8S0NIGF1EDOw8LlIs+VWB7DQL7wXJYbjQymyN/jf@vger.kernel.org, AJvYcCVKjlsLvuJQ1NwDa6tDE/NN6l4fLytxZzf4xadN02e5hOm65lpMcDuGNNRYeIdH6BDoo0nESRCIlPF8Wtv9@vger.kernel.org, AJvYcCVnxj/WuMWZq1Mfoi2QuPK+koww0YiUPipVdC228wbP3+zlqlK4sAy0mvRaXjP9YueRtfBlOWW31S+FXpo=@vger.kernel.org, AJvYcCXUaar8G2rfDg5itex5JYZFbr5XHoUL9tU3T+DDBNz/oR5sWlBb9XVyt/wsB1uaQulDfklH6YuVwkfE@vger.kernel.org X-Gm-Message-State: AOJu0YyC4+SLnsL8JKYWTvSSezp5tr1/RAKXRSuAsB9EM96ekyDLdbHT LQzhDZ48QJuT7H61d6fJAeK93cGnmvvDuWQkmwayWxpCCOYDKVcN X-Google-Smtp-Source: AGHT+IFoBL1R6dV7SQmlZLkBLTdCPdCS80FZbnIfOFtYbfTr6iXHb66aYiNtJGIPYb/itJ2vx6/jEQ== X-Received: by 2002:a05:600c:8a7:b0:42c:c003:edd8 with SMTP id 5b1f17b1804b1-42e96953e43mr23751955e9.6.1727300801042; Wed, 25 Sep 2024 14:46:41 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42e96a1f2aasm28802565e9.45.2024.09.25.14.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 14:46:40 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Christian Marangi , Simon Glass , INAGAKI Hiroshi , Daniel Golle , Al Viro , Christian Brauner , Li Lingfeng , Christian Heusel , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, Lorenzo Bianconi Cc: Christoph Hellwig Subject: [RFC PATCH v2 1/5] block: add support for defining read-only partitions Date: Wed, 25 Sep 2024 23:45:21 +0200 Message-ID: <20240925214544.6114-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240925214544.6114-1-ansuelsmth@gmail.com> References: <20240925214544.6114-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for defining read-only partitions and complete support for it in the cmdline partition parser as the additional "ro" after a partition is scanned but never actually applied. Signed-off-by: Christian Marangi Reviewed-by: Christoph Hellwig --- block/blk.h | 1 + block/partitions/cmdline.c | 3 +++ block/partitions/core.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/block/blk.h b/block/blk.h index c718e4291db0..f300212d3e98 100644 --- a/block/blk.h +++ b/block/blk.h @@ -558,6 +558,7 @@ void blk_free_ext_minor(unsigned int minor); #define ADDPART_FLAG_NONE 0 #define ADDPART_FLAG_RAID 1 #define ADDPART_FLAG_WHOLEDISK 2 +#define ADDPART_FLAG_READONLY 4 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, sector_t length); int bdev_del_partition(struct gendisk *disk, int partno); diff --git a/block/partitions/cmdline.c b/block/partitions/cmdline.c index 152c85df92b2..da3e719d8e51 100644 --- a/block/partitions/cmdline.c +++ b/block/partitions/cmdline.c @@ -237,6 +237,9 @@ static int add_part(int slot, struct cmdline_subpart *subpart, put_partition(state, slot, subpart->from >> 9, subpart->size >> 9); + if (subpart->flags & PF_RDONLY) + state->parts[slot].flags |= ADDPART_FLAG_READONLY; + info = &state->parts[slot].info; strscpy(info->volname, subpart->name, sizeof(info->volname)); diff --git a/block/partitions/core.c b/block/partitions/core.c index ab76e64f0f6c..abad6c83db8f 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -373,6 +373,9 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, goto out_del; } + if (flags & ADDPART_FLAG_READONLY) + bdev_set_flag(bdev, BD_READ_ONLY); + /* everything is up and running, commence */ err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); if (err) From patchwork Wed Sep 25 21:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13812446 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B602E1714CC; Wed, 25 Sep 2024 21:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300807; cv=none; b=jypAecmHeL6h0cwk8Po6QY4BY9ctgIm23Wb3BYm+YyOp8QyJhZtCgW0kYX2yUqc7pBioel5qIS1e3ds9gkeu4gKb30Ll84vppqVnUqzdjjnyiV9KXjbqRCE961SEN/UghF6rLZNuNCQQFzZuaubDOfIw20aKdNTZK2l6NBQyFLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300807; c=relaxed/simple; bh=AvSpeRPjeVRXz5j8dQKUo3Zt1JFIF3gH9S62HhEmPeo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gl7NOgIv3Go8Q1X5oKXr2KmSw5vt5puIvCzIeIOH8Bji6iTr0bSOnmyKduEZOBrgH9t2g0T1hs19pqj/0fAOIAe4VrOY+bUx9bbuaJTdqMhZA800ZQqAOSAfx6i+JpGMSVtFNd89Br2o84C0tajsvANL33PirXx8QCk7v0tmHxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TqWwFOr0; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TqWwFOr0" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42cb0f28bfbso2304055e9.1; Wed, 25 Sep 2024 14:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727300804; x=1727905604; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=36HmyHvoEEpKMI8/Stc+TIqGBije17bfud9rEk2jFTM=; b=TqWwFOr0VMoxMCQ30nc9YK5+dNm5NoHTlQXjuP5/dkVsl7FmhBQax4vX+IzJ5N25vw BcUDQFpIjlsSh+xfyEd5f4ZcLAQrhu1hmNJ59jIqb+vbTIIE7qTTfE43tpiqHBEFuGUf dMNarIinB8cFYiwC0Rt7b5HeIcmUYP2eACvAM6ugMfU8D+3531zcsxLV6wZGnZAzUWlk dBAM7Br1GDsUgTXbjSurmNDNvxaeUExCvEMMoQel/c70mVS8etJIuAynI0sRceb1GeUa 3qQTzlR7HN6trDErJgZJDqqFyhDxIREo669e4+b6pvY2svJube5ICuTXF4tg5plibBCq XjlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727300804; x=1727905604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=36HmyHvoEEpKMI8/Stc+TIqGBije17bfud9rEk2jFTM=; b=Vz+L8xuRgcY24VnwqLBEm2+SqDRCwqjaKD1X94ZXonyuZVnyGFCjbxo2Ub9kMUyEGi QleutXiSIhTewmWwvPLRZqaCST+iPvpqkwGHb6Q5AzmAMfTQyYAPmwpShJzhe1xvvXvx EjFZ87C/vcP95+0p8H7A2nJCS9Y1ztHWhXADaYMkMd/z51I+PwU6kuJfqX4tnVM+yOoo AzAuMz7kC2sNA292LqRSnd8A05vZtcq1tw7qG+yqjGwodBupUdPHGprje1T6t+rnDFaH 25P9zhLL/9cSteD3LDJ5s1iLWycvN4iEo/IjamsDPDpwNcivlpE2HqVl93kkJsZ4aYii GeLw== X-Forwarded-Encrypted: i=1; AJvYcCUqGxbh2A6+hSvmtb053fv0hDCd9UCj+4bA3AUkfq1YTYIgLCbZGSkBRZhuk+I+qxXtFezG+1WkndTi@vger.kernel.org, AJvYcCUrtnYUpZZxYwQpPYPKLW62VkuqwnqqCtU/S+89U9oS8xjs37WtHrYwy7WjR8t0ZkZMxtjdPHZ5vwqA@vger.kernel.org, AJvYcCV6zHZwJiZvLHbmdxkjr8PWDUI17hgDvxDwCSZvgplXuYLGesJdavIHAfRTqFgUOcwh4zqcB6ilEurGy2iG@vger.kernel.org, AJvYcCVHPQXBlfAmAiTlCMkmU7kZogbac8TgRLBFdIkbh1tLDimZpzzDcSlR+sGL/Bd/Y4xv4xivF7NynNRu@vger.kernel.org, AJvYcCWymTYxb0WkGtfthdebrGhTWsDe7srDfkS4fEbJyPW8KStuN3aZZgmgun/5td/gXNafChF3XR0FN1b7Ukw=@vger.kernel.org X-Gm-Message-State: AOJu0YxSRpWitjUOEK0INt2mQJPGFr4dl1swF7IJm7BwO51qp8yPufOf 1MiyT/QZdGOYtbeqBQ3OTj7xDvtHzR4d8/PW5uYixr0HzMWYZ4yn X-Google-Smtp-Source: AGHT+IFEGvmVDdovHjIR/TZhLA7blPbTqS8qJmoeaPcP9+ntt5+F1WQucpd+dgUvMfPNjk8XWg9Z1A== X-Received: by 2002:a05:600c:6003:b0:42c:a574:6362 with SMTP id 5b1f17b1804b1-42f50b68f6bmr21103775e9.11.1727300803624; Wed, 25 Sep 2024 14:46:43 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42e96a1f2aasm28802565e9.45.2024.09.25.14.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 14:46:42 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Christian Marangi , Simon Glass , INAGAKI Hiroshi , Daniel Golle , Al Viro , Christian Brauner , Li Lingfeng , Christian Heusel , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, Lorenzo Bianconi Subject: [RFC PATCH v2 2/5] docs: block: Document support for read-only partition in cmdline part Date: Wed, 25 Sep 2024 23:45:22 +0200 Message-ID: <20240925214544.6114-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240925214544.6114-1-ansuelsmth@gmail.com> References: <20240925214544.6114-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document support for read-only partition in cmdline partition for block devices by appending "ro" after the (partition name). Signed-off-by: Christian Marangi --- Documentation/block/cmdline-partition.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/block/cmdline-partition.rst b/Documentation/block/cmdline-partition.rst index 530bedff548a..526ba201dddc 100644 --- a/Documentation/block/cmdline-partition.rst +++ b/Documentation/block/cmdline-partition.rst @@ -39,13 +39,16 @@ blkdevparts=[;] create a link to block device partition with the name "PARTNAME". User space application can access partition by partition name. +ro + read-only. Flag the partition as read-only. + Example: eMMC disk names are "mmcblk0" and "mmcblk0boot0". bootargs:: - 'blkdevparts=mmcblk0:1G(data0),1G(data1),-;mmcblk0boot0:1m(boot),-(kernel)' + 'blkdevparts=mmcblk0:1G(data0),1G(data1),-;mmcblk0boot0:1m(boot)ro,-(kernel)' dmesg:: From patchwork Wed Sep 25 21:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13812447 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D385F176FDB; Wed, 25 Sep 2024 21:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300809; cv=none; b=CkNRYsvP1vqAL4u21Xdk7tfNVWulvLPjRZKu70+GGWMEN9S6OUm7ZIf1SwDXGhMTDw+Xu3y0q9A2kqpOu+IlIych9z180xt+hnNV/pKR6nIR4fTrIAoI72viwAqeRJpbbBYVBl86Q3iQA5uEZM3c9adxNhAciMFbvnxwx3iwsq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300809; c=relaxed/simple; bh=VWdNWKlk1VbmM4tp0dnQsKVCo70kSvcOAXNbnEvLBaM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dMdB2CB5DSEqCXe07zMsopFlH7yhnh5mRG2JTC/CCV1MpL/AS7/HnYh2GgyZA89rk5vUKMvVqOyVqv5wLMpUqN7EFUL2oUx5tB8SNDDi67erMYTTb72legf9UHGcrvqHMcVlfFpuki4z5NtCbz6JXLmmNcnH4tl5r+X29qdPVOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R8IXZBgC; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R8IXZBgC" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42cc8782869so2335015e9.2; Wed, 25 Sep 2024 14:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727300806; x=1727905606; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QgWHUdLDjVwovONqyKU9lTcOJXUFIpT+3p6c+7n8kok=; b=R8IXZBgCFiz6lf4gOp/Oe/uCIGoWl/rNqfd+KBFT5nHqvP6OBtZ34NeUhy593DKqyY VroxTba7n0CrgUIo8tPHeEH8B57bBpVY0Sai2I3gpRVjrBr0vgplHcUR/QQSGdnQxXXj VQlHoK57BW1jxw/weXoDsEU0zc19yPqW8auvedPu80RdLmdCVm6fhNQT/PKUDSICQlFO OvAVn+Q+XDXhFa0VX1M5VN93/ofPIMDdGP92rmmEGqSi66U4sdWTT5jGAm8cXKXY0zHh /EKB7VoHEZojE0Ld9334n1tgvQWLpziq4kNGJfXFHOp356tgsVnCe1wJZBUzktp6kyKR RInA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727300806; x=1727905606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QgWHUdLDjVwovONqyKU9lTcOJXUFIpT+3p6c+7n8kok=; b=tSCDKwOTnyOOuBF5GwW32q2VRrof8xmDNTCh/JdkfzQkQP2fif5DZ3UzaR2GzKKuzv KcTg4XKZ8aswWe8WS1rXIeb9488llmNi2YolJhf5sepynObOqA2Ryo6BSl5QaC7syAYt rj/qej3xVMyecZ6tDNdc766MZC1o3NTyYLHGREUt+tTczyvyVPOgSoxTTN+Vj1wuTnMT ZxZVT680l28czdqLkC0vy1pWLVJE1uovLVXFsBXRUqzJXthkwC6kb9urO60r0tj7xu7C JrlQYpUXpVU/DwXEoCnGm1pFBsqAh3F969Lf07IvyufMWK3ryCKiEpIRiO3fniqliPgL srKQ== X-Forwarded-Encrypted: i=1; AJvYcCUhYaSxCORd6720K8+I2LAT9kEME2xUFIopOmyMwTcVp01LRsyrb/qKrRlD9lfaKgLegcvbB1MWHKtCU0I=@vger.kernel.org, AJvYcCV7MRm8bz6cnaMJWSUlkb32Ns+9YLa1/Sae/ZkFeYyHvS+ZcaDQ43nKRcZJGKpEimAOWbRfYvBnWJo8@vger.kernel.org, AJvYcCVA/gBgCEXkKeC0luAxiTZe6hvhEBEKchFlstwQ1FcV5Bh8m+x3fl7fbZ0OfUs1MyFYC2ieyRBdbFOE@vger.kernel.org, AJvYcCVn/cAtf1+xvte+XuRA8PgJkqmqxxvU0tjWmErYIVP8Jz32JD597jYEPTU/RlKDVTs6jjNv9HskUImrdxOA@vger.kernel.org, AJvYcCXSedE2K5/DPZ1ttnvohe9n+Ylv2Lpd5kXY5eFqRHldm/BPaAciicmJw14/tXyKPxpgM1TMaj4biva3@vger.kernel.org X-Gm-Message-State: AOJu0YxD7Q0pZWZLglq+oJvyf3difTrT4ZpkhuytDB8XgKPjwjsHPDA7 SwOhnQNHLuk3ntcP3Q++Ln4D4uDauWFHlKsNrGp/9VXXLCBfEWyS X-Google-Smtp-Source: AGHT+IGXWHc3SskqLSYMunnZyVA254pi7dL+8Z+sk0Sjekr3pSPLjz3SFgIh9FFj6RbWe7uRZFuSaA== X-Received: by 2002:a05:600c:1c05:b0:42c:b63e:fea6 with SMTP id 5b1f17b1804b1-42e961362e8mr29653805e9.22.1727300805834; Wed, 25 Sep 2024 14:46:45 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42e96a1f2aasm28802565e9.45.2024.09.25.14.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 14:46:44 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Christian Marangi , Simon Glass , INAGAKI Hiroshi , Daniel Golle , Al Viro , Christian Brauner , Li Lingfeng , Christian Heusel , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, Lorenzo Bianconi Subject: [RFC PATCH v2 3/5] block: add support for partition table defined in OF Date: Wed, 25 Sep 2024 23:45:23 +0200 Message-ID: <20240925214544.6114-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240925214544.6114-1-ansuelsmth@gmail.com> References: <20240925214544.6114-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for partition table defined in Device Tree. Similar to how it's done with MTD, add support for defining a fixed partition table in device tree. A common scenario for this is fixed block (eMMC) embedded devices that have no MBR or GPT partition table to save storage space. Bootloader access the block device with absolute address of data. This is to complete the functionality with an equivalent implementation with providing partition table with bootargs, for case where the booargs can't be modified and tweaking the Device Tree is the only solution to have an usabe partition table. The implementation follow the fixed-partitions parser used on MTD devices where a "partitions" node is expected to be declared in the OF node of the disk device (mmc-card for eMMC for example) and each child node declare a label and a reg with offset and size. Eventually is also possible to declare the read-only property to flag the partition as read-only. For eMMC block, driver scan the disk name and check if it's suffixed with "boot0" or "boot1". This is to handle the additional disk provided by eMMC as supported in JEDEC 4.4+. If this suffix is detected, "partitions-boot0" or "partitions-boot1" are used instead of the generic "partitions" for the relevant disk. Signed-off-by: Christian Marangi --- block/partitions/Kconfig | 8 +++ block/partitions/Makefile | 1 + block/partitions/check.h | 1 + block/partitions/core.c | 3 + block/partitions/of.c | 144 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+) create mode 100644 block/partitions/of.c diff --git a/block/partitions/Kconfig b/block/partitions/Kconfig index 7aff4eb81c60..8534f7544f26 100644 --- a/block/partitions/Kconfig +++ b/block/partitions/Kconfig @@ -270,4 +270,12 @@ config CMDLINE_PARTITION Say Y here if you want to read the partition table from bootargs. The format for the command line is just like mtdparts. +config OF_PARTITION + bool "Command line partition support" if PARTITION_ADVANCED + depends on OF + help + Say Y here if you want to enable support for partition table + defined in Device Tree. (mainly for eMMC) + The format for the command line is just like MTD fixed-partition schema. + endmenu diff --git a/block/partitions/Makefile b/block/partitions/Makefile index a7f05cdb02a8..25d424922c6e 100644 --- a/block/partitions/Makefile +++ b/block/partitions/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o obj-$(CONFIG_MAC_PARTITION) += mac.o obj-$(CONFIG_LDM_PARTITION) += ldm.o obj-$(CONFIG_MSDOS_PARTITION) += msdos.o +obj-$(CONFIG_OF_PARTITION) += of.o obj-$(CONFIG_OSF_PARTITION) += osf.o obj-$(CONFIG_SGI_PARTITION) += sgi.o obj-$(CONFIG_SUN_PARTITION) += sun.o diff --git a/block/partitions/check.h b/block/partitions/check.h index 8d70a880c372..e5c1c61eb353 100644 --- a/block/partitions/check.h +++ b/block/partitions/check.h @@ -62,6 +62,7 @@ int karma_partition(struct parsed_partitions *state); int ldm_partition(struct parsed_partitions *state); int mac_partition(struct parsed_partitions *state); int msdos_partition(struct parsed_partitions *state); +int of_partition(struct parsed_partitions *state); int osf_partition(struct parsed_partitions *state); int sgi_partition(struct parsed_partitions *state); int sun_partition(struct parsed_partitions *state); diff --git a/block/partitions/core.c b/block/partitions/core.c index abad6c83db8f..dc21734b00ec 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -43,6 +43,9 @@ static int (*const check_part[])(struct parsed_partitions *) = { #ifdef CONFIG_CMDLINE_PARTITION cmdline_partition, #endif +#ifdef CONFIG_OF_PARTITION + of_partition, /* cmdline have priority to OF */ +#endif #ifdef CONFIG_EFI_PARTITION efi_partition, /* this must come before msdos */ #endif diff --git a/block/partitions/of.c b/block/partitions/of.c new file mode 100644 index 000000000000..fdc033107bcb --- /dev/null +++ b/block/partitions/of.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include "check.h" + +#define BOOT0_STR "boot0" +#define BOOT1_STR "boot1" + +static struct device_node *get_partitions_node(struct device_node *disk_np, + struct gendisk *disk) +{ + const char *node_name = "partitions"; + + /* + * JEDEC specification 4.4 for eMMC introduced 3 additional partition + * present on every eMMC. These additional partition are always hardcoded + * from the eMMC driver as boot0, boot1 and rpmb. While rpmb is used to + * store keys and exposed as a char device, the other 2 are exposed as + * real separate disk with the boot0/1 appended to the disk name. + * + * Here we parse the disk_name in search for such suffix and select + * the correct partition node. + */ + if (disk->major == MMC_BLOCK_MAJOR) { + const char *disk_name = disk->disk_name; + + if (!memcmp(disk_name + strlen(disk_name) - strlen(BOOT0_STR), + BOOT0_STR, sizeof(BOOT0_STR))) + node_name = "partitions-boot0"; + if (!memcmp(disk_name + strlen(disk_name) - strlen(BOOT1_STR), + BOOT1_STR, sizeof(BOOT1_STR))) + node_name = "partitions-boot1"; + } + + return of_get_child_by_name(disk_np, node_name); +} + +static int validate_of_partition(struct device_node *np, int slot) +{ + int a_cells, s_cells; + const __be32 *reg; + u64 offset, size; + int len; + + reg = of_get_property(np, "reg", &len); + + a_cells = of_n_addr_cells(np); + s_cells = of_n_size_cells(np); + + /* + * Validate offset conversion from bytes to sectors. + * Only the first partition is allowed to have offset 0. + */ + offset = of_read_number(reg, a_cells); + if (do_div(offset, SECTOR_SIZE) || + (slot > 1 && !offset)) + return -EINVAL; + + /* Validate size conversion from bytes to sectors */ + size = of_read_number(reg + a_cells, s_cells); + if (do_div(size, SECTOR_SIZE) || !size) + return -EINVAL; + + return 0; +} + +static void add_of_partition(struct parsed_partitions *state, int slot, + struct device_node *np) +{ + struct partition_meta_info *info; + char tmp[sizeof(info->volname) + 4]; + int a_cells, s_cells; + const char *partname; + const __be32 *reg; + u64 offset, size; + int len; + + reg = of_get_property(np, "reg", &len); + + a_cells = of_n_addr_cells(np); + s_cells = of_n_size_cells(np); + + /* Convert bytes to sector size */ + offset = of_read_number(reg, a_cells) / SECTOR_SIZE; + size = of_read_number(reg + a_cells, s_cells) / SECTOR_SIZE; + + put_partition(state, slot, offset, size); + + if (of_property_read_bool(np, "read-only")) + state->parts[slot].flags |= ADDPART_FLAG_READONLY; + + info = &state->parts[slot].info; + partname = of_get_property(np, "label", &len); + strscpy(info->volname, partname, sizeof(info->volname)); + + snprintf(tmp, sizeof(tmp), "(%s)", info->volname); + strlcat(state->pp_buf, tmp, PAGE_SIZE); +} + +int of_partition(struct parsed_partitions *state) +{ + struct device_node *disk_np, *partitions_np, *np; + struct device *ddev = disk_to_dev(state->disk); + int slot; + + disk_np = of_node_get(ddev->parent->of_node); + if (!disk_np) + return 0; + + partitions_np = get_partitions_node(disk_np, state->disk); + if (!partitions_np) + return 0; + + /* Check if child are over the limit */ + slot = of_get_child_count(partitions_np); + if (slot >= state->limit) + goto err; + + slot = 1; + /* Validate parition offset and size */ + for_each_child_of_node(partitions_np, np) { + if (validate_of_partition(np, slot)) + goto err; + + slot++; + } + + slot = 1; + for_each_child_of_node(partitions_np, np) { + add_of_partition(state, slot, np); + + slot++; + } + + strlcat(state->pp_buf, "\n", PAGE_SIZE); + + return 1; +err: + of_node_put(partitions_np); + of_node_put(disk_np); + return -1; +} From patchwork Wed Sep 25 21:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13812448 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9093C158866; Wed, 25 Sep 2024 21:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300812; cv=none; b=gKK6SkVre2b0JKRrqdLIuKDtMSH+oDZmBE4CXl0VodZ5lHJW3bZMXDTxDAWSciKa4LwdAA5nxXm7ngsxRNgkjD1A+9olKNxscmTNYxDz3lEI3Xu6lt1li5i9GjgGFGR7/WwNr++ytgvB4eGRLT8gfJpBgH+FpFmIbLDalT7hffE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300812; c=relaxed/simple; bh=JRS8ctlAm3qYU/7UxMl0igxy25UFiLYuqzTjAkmm7t4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tto4mCGxR0TuSjwIOf3mVnxm/bfXUjHczt58k68v7/zqGC58NrMn0u3kKHbfKtx338yB0hEXddsUhgCHuJq4zhak+RxbfW3cDw9lX9XHvkskFbU2lMbCJqtcxyldzZxL3LQPLAW645sB18YVqQOcQk5iKGvwNq3fK48Gp1cJjt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JTW7cVBm; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JTW7cVBm" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42cd46f3a26so2340905e9.2; Wed, 25 Sep 2024 14:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727300809; x=1727905609; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mPfCoOMxsJjIr/wXEPPqXPDSbCfoVOLl/AUDyDHyFMM=; b=JTW7cVBmt6wPnj4wTGt7cCGaAffTOsekWNhufpwECg7i1l0fnnEsZlWxlzv0DPv5ts OaWsJt1Y7lnl5k1cbvfAEOU6mty9Zo8ci7HTOHpLFGyh3itagTUtIRbJSVBwDAR6Nnhv JUtXc5CVERzEDI2ViUwhFMp4VCSUVmB2YmAwuGqioysGB/Mu9JSJvfGs796FTZf7L5xo CW8YSI11gvnyDd7i2+2w+qtEWTcLGNG48gG9oEr4v2Wo/5fv+r+YoPlzf8TpxnzM4Djt eLCylenht1TcOTxtijpFB+1xZ/SnBUaRREa9WaFAypAr4BBoFPjIVBkqT37Jse1LQNIt Goug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727300809; x=1727905609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mPfCoOMxsJjIr/wXEPPqXPDSbCfoVOLl/AUDyDHyFMM=; b=jFm7sDCFk8lYOpvXvfSBbWL8W66FCcYAFg6jPGf22CrrCz3vmI0lOKbW3mF11stqOy FW30uEORQOaupSt5OWc0jIBMmYJG0KXvl+4zCbIJ7BmMTmFAwV84lxfyC/MyunDksXj1 jf5dAh8nISLlq057pmLXH0DE5/hNykW9X72RzQQ93qaae5BPSC4hz266h35R3QK3XXwO JyJJMdtNcYnrD45/wonyuzJ4+lPN8ArQm0tgP6YL5/ZL/n/nilw649b0u4j/Kw3fUUkd grdtAnRRRBl0URq9S1NI/50uABPj+oLwTnzipLPNe3+L9aWKdDOwQtZGhi3MmmfCzLRI FxrQ== X-Forwarded-Encrypted: i=1; AJvYcCU4cJD78LAZtGx+xdDQ9R/r5w9W+DyKZpbB42u730tGqn8FfTHA0JoQVG7qQMCIpWHaKsffOOx6eq5KT+Ue@vger.kernel.org, AJvYcCV1PwPGDI2NpwvVFfTaw7EudkpI3WjbXf/WGML98TOXpw1LkmWqFYvHfYyb7uUfzFpGgWsToqnRqeBd5FU=@vger.kernel.org, AJvYcCW767O3EbOeyRz1FznHLPEnPBUgMn5CC0ix581DXkuDV39f9XNqJ3ym/RH0L00HD2SQtPeimmNxDW93@vger.kernel.org, AJvYcCXKT4D+DlfBEbUx1e3E4I1636ugA6uKJGw9+uZbjwx2FFnNmBtES26Z4gA0NgnuQlAIZ0WAdQy8/yac@vger.kernel.org, AJvYcCXNZVqDvquh7JUi+1ZX/hhryGgFyp4XZVxcETtnFmNzrBWk8QV6C4U0q+iZs8Zwh+IGD473+XeWXffZ@vger.kernel.org X-Gm-Message-State: AOJu0YzX7SlKfuh0GuIH1Aj5/z98qwQaetDA6UXw7SBrVFRwQC/IVJEH Bnrfx1iEbogy4mxKq3IRGfJNzAi7/g/RLKOKvXjrcVkZHuLnyTHK X-Google-Smtp-Source: AGHT+IGTce5mi+zGP1nqXGGDPQZkUaai36raLWa1UNPSL60TCBSVV7e7UIdYpJYbrhcAnUbxRz9g7A== X-Received: by 2002:a05:600c:1910:b0:42c:b9b1:8342 with SMTP id 5b1f17b1804b1-42e96119514mr26588975e9.19.1727300808654; Wed, 25 Sep 2024 14:46:48 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42e96a1f2aasm28802565e9.45.2024.09.25.14.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 14:46:47 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Christian Marangi , Simon Glass , INAGAKI Hiroshi , Daniel Golle , Al Viro , Christian Brauner , Li Lingfeng , Christian Heusel , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, Lorenzo Bianconi Subject: [RFC PATCH v2 4/5] dt-bindings: block: Generalize and introduce property for partitions Date: Wed, 25 Sep 2024 23:45:24 +0200 Message-ID: <20240925214544.6114-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240925214544.6114-1-ansuelsmth@gmail.com> References: <20240925214544.6114-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Generalize property from MTD partitions schema and introduce property for block partitions defined in OF. Partition schema for block devices is a reduced schema of the MTD as only a few property are supported for it. (reg, label and read-only) Signed-off-by: Christian Marangi --- .../bindings/block/partitions/partition.yaml | 33 +++++++++++++++++++ .../bindings/block/partitions/partitions.yaml | 27 +++++++++++++++ .../bindings/mtd/partitions/partition.yaml | 10 ++---- 3 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/block/partitions/partition.yaml create mode 100644 Documentation/devicetree/bindings/block/partitions/partitions.yaml diff --git a/Documentation/devicetree/bindings/block/partitions/partition.yaml b/Documentation/devicetree/bindings/block/partitions/partition.yaml new file mode 100644 index 000000000000..b9b1d8139e56 --- /dev/null +++ b/Documentation/devicetree/bindings/block/partitions/partition.yaml @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/block/partitions/partition.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Partition + +description: | + This binding describes a single flash partition. Each partition must have its + relative offset and size specified. Depending on partition function extra + properties can be used. + +maintainers: + - Christian Marangi + +properties: + reg: + description: partition's offset and size within the flash (in sector + block, 512byte) + maxItems: 1 + + label: + description: The label / name for this partition. + + read-only: + description: This parameter, if present, is a hint that this partition + should only be mounted read-only. This is usually used for flash + partitions containing early-boot firmware images or data which should + not be clobbered. + type: boolean + +additionalProperties: true diff --git a/Documentation/devicetree/bindings/block/partitions/partitions.yaml b/Documentation/devicetree/bindings/block/partitions/partitions.yaml new file mode 100644 index 000000000000..9c161aac364d --- /dev/null +++ b/Documentation/devicetree/bindings/block/partitions/partitions.yaml @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/block/partitions/partitions.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Partitions + +description: | + This binding is generic and describes the content of the partitions container + node. + +maintainers: + - Christian Marangi + +properties: + '#address-cells': + enum: [1, 2] + + '#size-cells': + enum: [1, 2] + +patternProperties: + "^partition@[0-9a-f]+$": + $ref: partition.yaml + +unevaluatedProperties: false diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml index 80d0452a2a33..e822d3219b68 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml @@ -6,6 +6,8 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# title: Partition +$ref: /schemas/block/partitions/partition.yaml + description: | This binding describes a single flash partition. Each partition must have its relative offset and size specified. Depending on partition function extra @@ -28,19 +30,11 @@ maintainers: properties: reg: description: partition's offset and size within the flash - maxItems: 1 label: description: The label / name for this partition. If omitted, the label is taken from the node name (excluding the unit address). - read-only: - description: This parameter, if present, is a hint that this partition - should only be mounted read-only. This is usually used for flash - partitions containing early-boot firmware images or data which should - not be clobbered. - type: boolean - lock: description: Do not unlock the partition at initialization time (not supported on all devices) From patchwork Wed Sep 25 21:45:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13812449 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D77E183CCB; Wed, 25 Sep 2024 21:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300816; cv=none; b=lxwz2Clo4F1FoaT9dASy7oci63beLFRr3Mevl47tIS9st5RR/+QlupsU08SkHBnsqbsnJabHQwMV84noQIikAnCeo70iSMxr0nrnTFPwb0l6yxomCN3ONisJ3Jd6Xe9liGFASOVjeBmN0SUWLnmwDTghm9eo9BOuiDv4WJLmQtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727300816; c=relaxed/simple; bh=FeHxkCsjuNWL4fLxU+cdqB1g5g+6e0/6atm4D7lPtT8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FYAf2aqsfZRVli9Hqyavr9T4ci6dy/ZrMUJKavFIYHeB3nKAcJJHAYBpMS7UXAv0OZnJMLNUvhKpQ6t0ygEQ5mwJO60rN+9+XLPInSvPfUXJK81wSajLlSMjbb1TR5mzFWq0wmfgKxZQPAglIhuKY5Gr2tTN0yOXQPk2kg/BynI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cKrrdVbw; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cKrrdVbw" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-37cc5fb1e45so163542f8f.2; Wed, 25 Sep 2024 14:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727300813; x=1727905613; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=d9nJBatBeRhZqG9r4m0SatNAaTtD+mKgW27WzTrnpaU=; b=cKrrdVbw8WMQaaHu5TuAQWGFVeNSWAfDH69/W0MdnZCjwPc/5H2FRQvwIZXQ+otbwf OpE3M/jo2YVIfGir0gLBPoKgjT1L+P1rYDhwPM8qtIn/naE5E4awGaNwhpva10mxO6B6 VszGXjFX8u0BGiN6eQL8pPABk6qocpyoWCf3WGR2bslpx++JCCQO9q/HfVMluu1vD5zN nBIIKHv8i1PBIpXrd1et+21HEk1uf9xYH2r66tkl21KHsP21zf0nAbJzDhDndRg0wAwd 5Uart59LAg87iNnfRNznreRgHUAwpm9yyq/8/ikwzZ/PvmUG5PIdbyzx9RhAxNx5FXh6 aaLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727300813; x=1727905613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d9nJBatBeRhZqG9r4m0SatNAaTtD+mKgW27WzTrnpaU=; b=kW8q3YB6ztiN6RCJQtR+SFi0EDfyoKhAaIBs/l+/cbbKD8xkgTP14ptzpQ4TrUwZEb F4txmQce4N0Ce8QTkk4ADcAy2CxJA9E2rwNzZbWigDgdNpIsEgQjufSXnE2kL9a05O4A iCGWn9awbGXWqb6RdYa9ndHyWGpXRZ+r7mhKNXVb6Jr1nkKAQ9Mact8/izEyVDl2ZBNN BIYbdgQnY9NtsW01LqRXVjXWEhoU+4ohfABs6ytj6h8fpVGN6nu521SR/lwKuDgbuych PD73d7WWRZ/MRJjQNxKu2IM4qOOxr1y18g6hHydF1eZdj8oNAko1UvtRO2mMoA8MmHvP DJGQ== X-Forwarded-Encrypted: i=1; AJvYcCUWv4SrX+szq8G/DOWDcAFHE6V1y2rKx5fUmmrsSw3q+qiWYu6sloVoD5CO4ui/TKDxSK/3IsKaiuNz@vger.kernel.org, AJvYcCVOdI/ylun78/0K9vHqZRgGao3IeRF7smzKcv+/pses5K3VDuRQDVy8Q0oIi8iBNMCXk7hH+x7GQfikAGg=@vger.kernel.org, AJvYcCVVd9xyvGK3bhRkPKlA3iuthA72IbnBKttTg6kz/cFwnJp2dV1ZRtNFifldGa8X13DVgj0tWxqjo5H6@vger.kernel.org, AJvYcCX1Kui7lfHYNPp+cHZzt1Ilz8E3FsditsHudWRupz7eVrtq9M7nDt/L+Janu47II/EGaox0b027HTzM@vger.kernel.org, AJvYcCXcUQinFyXN41+YWNjDNGg++0z2Fo3Js78DHqC1oUACXutl2cD43TJOv/OxaHgii5p7mkzTLr36rscKyCau@vger.kernel.org X-Gm-Message-State: AOJu0Yxp9xAk6yNHfBD04EiEP1/+9V/phrL8Y7rH3JVlEodJCuT5/3QB 7GCOYNDBf7VsH4jMPqhEQBtHpbvoaHhQPPykyzf+CadftYXBP7EP X-Google-Smtp-Source: AGHT+IGZAeyKrzKHwOIGMyU2gN/Hnw0mA0ZY+Q9ejwmwD5hxO/FVKoUk2mqdLL+JRkRUMynqLB4o7Q== X-Received: by 2002:a05:6000:120a:b0:374:c847:852 with SMTP id ffacd0b85a97d-37cc247944dmr2442137f8f.29.1727300810823; Wed, 25 Sep 2024 14:46:50 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42e96a1f2aasm28802565e9.45.2024.09.25.14.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 14:46:50 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ulf Hansson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Christian Marangi , Simon Glass , INAGAKI Hiroshi , Daniel Golle , Al Viro , Christian Brauner , Li Lingfeng , Christian Heusel , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, Lorenzo Bianconi Subject: [RFC PATCH v2 5/5] dt-bindings: mmc: Document support for partition table in mmc-card Date: Wed, 25 Sep 2024 23:45:25 +0200 Message-ID: <20240925214544.6114-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240925214544.6114-1-ansuelsmth@gmail.com> References: <20240925214544.6114-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document support for defining a partition table in the mmc-card node. This is needed if the eMMC doesn't have a partition table written and the bootloader of the device load data by using absolute offset of the block device. This is common on embedded device that have eMMC installed to save space and have non removable block devices. If an OF partition table is detected, any partition table written in the eMMC will be ignored and won't be parsed. eMMC provide a generic disk for user data and if supported (JEDEC 4.4+) also provide two additional disk ("boot0" and "boot1") for special usage of boot operation where normally is stored the bootloader or boot info. Signed-off-by: Christian Marangi --- .../devicetree/bindings/mmc/mmc-card.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.yaml b/Documentation/devicetree/bindings/mmc/mmc-card.yaml index fd347126449a..58b6593a0f60 100644 --- a/Documentation/devicetree/bindings/mmc/mmc-card.yaml +++ b/Documentation/devicetree/bindings/mmc/mmc-card.yaml @@ -13,6 +13,10 @@ description: | This documents describes the devicetree bindings for a mmc-host controller child node describing a mmc-card / an eMMC. + It's possible to define a fixed partition table for an eMMC for the user + partition and one of the 2 boot partition (boot0/boot1) if supported by the + eMMC. + properties: compatible: const: mmc-card @@ -26,6 +30,30 @@ properties: Use this to indicate that the mmc-card has a broken hpi implementation, and that hpi should not be used. + "#address-cells": + const: 0 + + "#size-cells": + const: 0 + +patternProperties: + "^partitions(-boot[01])?$": + $ref: /schemas/block/partitions/partitions.yaml + + patternProperties: + "^partition@[0-9a-f]+$": + $ref: /schemas/block/partitions/partition.yaml + + properties: + reg: + multipleOf: 512 + + required: + - reg + - label + + unevaluatedProperties: false + required: - compatible - reg @@ -42,6 +70,35 @@ examples: compatible = "mmc-card"; reg = <0>; broken-hpi; + + #address-cells = <0>; + #size-cells = <0>; + + partitions { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "kernel"; /* Kernel */ + reg = <0x0 0x2000000>; /* 32 MB */ + }; + + partition@2000000 { + label = "rootfs"; + reg = <0x2000000 0x40000000>; /* 1GB */ + }; + }; + + partitions-boot0 { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bl"; + reg = <0x0 0x2000000>; /* 32MB */ + read-only; + }; + }; }; };