From patchwork Mon Sep 23 10:59:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13809502 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 D73AD19882B; Mon, 23 Sep 2024 11:00:10 +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=1727089212; cv=none; b=DkOP6XlYUVVimBrbxoRJJ2g/k1IUJ4CPVUeJ6UFWIEuPQ3cGbzcOyGDpDDZ+QX6HgVcCBUFCQWXHwP9QV9fWsTVKaBgoIPeFj+U5ZvjiQDR8XxNHTA9NmIRHq2xDpD3bsNJrqInuG3dMor6t6780o3+7hkNK4CyKpQgJ95tByVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727089212; c=relaxed/simple; bh=PWT+1guXrrHd8w41xmplQKn+dnohAlXRG9k9pw7PGLM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=css7qjX+ge2Z4EY44jLoiA5m4FH4+kw0W8HckV0WDG0y8gCenbKpDbvfYRiaV59x1oq9azV8PT6vPE+4k5gLUDD01mgtn8c9puqzGVIEdN+HSkTzvy3MPo1B5DDl22Ob863mEj7JUgHm8GKS3gGt7PjF2VNinOpN9pmTUqd/3fk= 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=EOumoSis; 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="EOumoSis" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42cc8782869so39930125e9.2; Mon, 23 Sep 2024 04:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727089209; x=1727694009; 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=x09MtPWWqEWKkV0nUWpUR8LWmcgDU81FVOPMzYJK1Qw=; b=EOumoSis7aSRovGGsaH4K77u1WaHi2Wh12u3BPNBXHTkFz5QZ19BgZH1M1s8T92vxr o5iID4RdGGrSrDmhYQHWdjBz9pzEqWj49pUH5Uv8IWa2nqmzzGMgL+0eDs4fSYSPj4lV kz1Y+HlJVeRGtyDkJbkzgiI91wzFErOuWs/gREHhtmA+9+7qYskqlZfr56/uBBQHIEFg BSPG6uv6YEU1ujm3n+CUg4GHRjj9casKGFv1EdOV9dYRt0tVi3WJW8UTLS0WS9BxRbnk uHpixl7Df4Yf/TqGXQzI6gFOG0Nd2n45dc0AnZrJ/H70rKzKjevMa3LFQU7/xTTJ9Mv9 bqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727089209; x=1727694009; 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=x09MtPWWqEWKkV0nUWpUR8LWmcgDU81FVOPMzYJK1Qw=; b=T15Tnp0OCtIItudX3zQ+7CE8jIXPzBXgvfKRQLZEMIVq6SvEivc98xOA83LE2dx+B3 D9iMjrA/ujbP/dPrDnjUy3rjciceCTN6QHx2gtngaub4vnA3cSWBAGT8a+kW+/hN6UdO N9O8Emp6AFe3MzbSaZfyc4e2dlksBBhrI2ue6U3iq0HBwXkL9KRCN6yEuyu2zl1myBgT dFadODnqdp5zWiD5qXWcL3stEuvZ1REbDmvP/cfyhHwV6uZVcKJ9HYdq7TFeOVjNNjk9 7XWAXpc0P43jq4PzT98OYn11lyql+42tOhy4SxK+pZT6TI1DDGJ0+ml3okcIiRcMsTjN oz6A== X-Forwarded-Encrypted: i=1; AJvYcCU0Vrqzkzwr218fzrwksfnSOsJV3VlRfpKVuxYDYpUThtH+bJ/K2k3HqoyUM1FC9J+EIh898c4FEWNW35jP@vger.kernel.org, AJvYcCUTYjXLbSoQqotKrbxCFesY1Hkn5PRR5eX7/4A6DA9oWWNxdRNrRV4tv9u3s152DSOHuFalRMRFnxDhYGs=@vger.kernel.org, AJvYcCWzhCVJnjP38eMNwMT7aNMn02t8NPhv7ImVzuK1qi5JB3+xaWaTQBMbPc0QdDWnlHUXrVyZUdklyEGL@vger.kernel.org, AJvYcCXJAmLgCMnzGbnjv/lI1eoeP71of5PmY5z8AXMndizciZ+e0dxB86cXOdm5EpxyxM6HAaVrVr0eA6qX@vger.kernel.org, AJvYcCXXxXdS8qBC80+3D3EApLU5BAt+0djlmdY3lV3lPy7PFPWn/uQv81j+LnwKsbY/OsYtoUesXYK2uZpx@vger.kernel.org X-Gm-Message-State: AOJu0YwDj+lxs5HM9AYg98jTKI6nxZkkyRvC9jiJiBChqBsdumXpAMT5 8pLZN2HVHimaFzUGNU/YISz8aInE4beGM1oU7PAKXM0/m+wmL/mA X-Google-Smtp-Source: AGHT+IEU5HQ3C058+0DbY6a8UrN+weOTz7jAFhcqQ1j0WR4Tk3irm7jxbjBcvbwYMsdt/6iiNwqK8g== X-Received: by 2002:a05:600c:46c6:b0:426:5416:67e0 with SMTP id 5b1f17b1804b1-42e8024f86bmr55011745e9.31.1727089208797; Mon, 23 Sep 2024 04:00:08 -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-42e7afd7490sm97856615e9.28.2024.09.23.04.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:00:08 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , INAGAKI Hiroshi , Daniel Golle , Christian Brauner , Al Viro , Ming Lei , Li Lingfeng , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi Subject: [RFC PATCH 1/4] block: add support for defining read-only partitions Date: Mon, 23 Sep 2024 12:59:30 +0200 Message-ID: <20240923105937.4374-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240923105937.4374-1-ansuelsmth@gmail.com> References: <20240923105937.4374-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 --- 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 Mon Sep 23 10:59:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13809503 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 101B2198830; Mon, 23 Sep 2024 11:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727089213; cv=none; b=DVdLa6kJmKEszQOQINF4mnSSiJ6TefyIV+JC9p6PDSUZIJtCPWcf095lM+3KM8sepGSgFBDHvQRoNowPM8m/PukVHKDP9l94lvn6AE56nkYj89NZN9azobGGAEPZ718AZtWn2eERXOMh8JETc9NFQTx2s3vNhuzYr9gudI86M28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727089213; c=relaxed/simple; bh=AvSpeRPjeVRXz5j8dQKUo3Zt1JFIF3gH9S62HhEmPeo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SUQf4EPscxJdurdNgEyqjEu140mUJXtzQitKaanWNMEQCpa1Yg7ZS5k0s1IfoGyRlM3nTqfUIb/7DzxecKjKV95X6yPi0rC2n60U+RDFumrOOPXhPEr9HcjXGtM/dBk0J3Ktxz+tnGkLM/gtE+Xo/uAGkhqrV7eQzBRPm5WdZeE= 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=BxoNxUxJ; arc=none smtp.client-ip=209.85.128.53 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="BxoNxUxJ" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42cbb08a1a5so39905405e9.3; Mon, 23 Sep 2024 04:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727089210; x=1727694010; 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=BxoNxUxJZfwMU+JB+Fm3dhYhMzfZaCky564j+nP72FDVZV/J5XcH2PwPDdTGLgvGlq /hiOVbhvVFFW7eeia3A7lBl0SkhPgx7DVA6zbyn2KFvGEVPkuuBtGWwraSlQeKAYlSrm IJ+zY/zGkzwgavIUVXe4wG1qQE3WgW2WQOnOTXkka2CndNC4Sn1AVnH8I+qmeYU7jmHr nImRw0S5nux11mZohz90a/bQ2vEBiSZn4XM3Fd9FOzTPbJbOhM63ukWbxR06h/CKu/vO bGEVC2OVzEsTP2HEvkWcfv3BszgzclUbK06t2kJ412dPFpU4gegFvRxiLQbtRxsZu99b au8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727089210; x=1727694010; 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=AfFYZSGpzfeH8k4+27bR2DS6UB0QaUUcmmktUuMhH4dTi9A/PLjAjWnp/3VfeeMw+P cDWc0m5EK2DAsVbcoTRLTTDfebxrZ0Kvn1LcgD5GcFLS92aSEBOWTLyruC4wCGGC94iz wi/+mfTy2QnrEUKbf4FaukHNXj31XgNTX0ddv4ajhM3tvfFG1Cf/ZpNV0wq0srCIAX0B egxFq3vRBrPnWKKRGvugdbixSjrydXzA3UxEd/OxP5fju/skkg3iipPr/ZIF1GSE7QJy nOKsgyT1jlNqLdLuKSJXTtZ1gZ4NiAoI+HRvZgjkrDzLIu4JKigsIwSkzA/FJiQf01Fr Fsdg== X-Forwarded-Encrypted: i=1; AJvYcCU2Dm3zW19Pie2PJGh6wXkeM29SJlwAp62hNoy4LGcSixZwBhY95p+CZkKKzrhzGKvzK/LYL2hKew9V@vger.kernel.org, AJvYcCVOUPK2SffUw8DZvsi9HCuFw8Exvn6g/hXRtfjBmdm69y7CSwnTL9Rhwk+LS0C1yZg7485Ttpv57vsgiEsk@vger.kernel.org, AJvYcCVvu5EFRiONWTfTVvptEYz0xjlK+rUbCdNhYhrps6URQGwi5AQXMiH3eXN7Bn6ZLoLX4v6PJT506fhS@vger.kernel.org, AJvYcCWw1kPGMHxJjtZGr7Vth1cZ3o9hZijFABIxDWH4rqvncfPDyHfC8ESjf8Ygh2VhMCmGQ5X0d6Tdy42d@vger.kernel.org, AJvYcCXwdmgHZaEL2WXiuUUOmLFl95WC4ZNNJWU2i0fH5giHke14ehQsO6gJTAl8jTGRnIEnec9+CPqylJ370Pk=@vger.kernel.org X-Gm-Message-State: AOJu0Ywi8gKFxDce+dFpriWeUNO3+0AEWZyIlfm0r4ATW3hSJIC10ehr cw8c4UpFOHdTr+UBzZ1FramngBJjaoWamwAaLJoNa0cWLVXEgBh5 X-Google-Smtp-Source: AGHT+IFgo28Z5y1d9oL3jd8zd0ceuYYzEDnbDY27ygnKWGg1jKQU8CYFnsybLuTT1dqbvrzcAt72Qw== X-Received: by 2002:a05:600c:1c04:b0:42c:bb41:a077 with SMTP id 5b1f17b1804b1-42e7ada4c7cmr74426875e9.23.1727089210051; Mon, 23 Sep 2024 04:00:10 -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-42e7afd7490sm97856615e9.28.2024.09.23.04.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:00:09 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , INAGAKI Hiroshi , Daniel Golle , Christian Brauner , Al Viro , Ming Lei , Li Lingfeng , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi Subject: [RFC PATCH 2/4] docs: block: Document support for read-only partition in cmdline part Date: Mon, 23 Sep 2024 12:59:31 +0200 Message-ID: <20240923105937.4374-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240923105937.4374-1-ansuelsmth@gmail.com> References: <20240923105937.4374-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 Mon Sep 23 10:59:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13809504 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 5BAE9198E81; Mon, 23 Sep 2024 11:00:13 +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=1727089215; cv=none; b=bAXf5z2kqxejGWMcnkY+QXKtRNc5M4nv2Hqpuppo1N3IyGUwBVnu2LMFZt9CsezY/VYnSCMaDaqVxTXl76MrFwhziFf2krWXnK4InnXwk5lNWUyE+bv2kRdX9pwKNyyDgmNi0S/UDkyaC6SPSSodcSSE/BhN4COvndDrKtBjlZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727089215; c=relaxed/simple; bh=AAUW5AeuiKrXpIHD/TmOnrKvsD3GPu+ctHY8R9WVrbw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AXaj1tncZawqu6EMjqqOJC0YdlHeJX1I3c71NGuI9eGD4brvcXROXIasFno5DmR+t7p0cwT61bJd/xk/NtqrVPGfvUzTgpBou/7ROJlVuBcxXsD8H2nAYOdu4XpBn5PdDsxueKYzRTckPdoezVxNNVT4NtReGw5Vn7TVsN9OJug= 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=Wh6FPr4E; 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="Wh6FPr4E" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42cb7a2e4d6so38068295e9.0; Mon, 23 Sep 2024 04:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727089211; x=1727694011; 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=0J8gDMucjxpOg+RLl5wRybpqYOL20vywcDEytKDdvEc=; b=Wh6FPr4EzoBUSHyU4cvFmIpaH/Dfgd5oep1Lbz28d6FahA46Z9VTcNuVzIUUbbhwW8 SwPi+TejIBU68/2Cil0v3794aoiAdRO78Jr3U7jDZ+Dd+yI7n8SVeOyhXgRQnw/A5GeD ACbhsMk9PiKt7aX/s3iG2F3O+QedUsrTL6gNvGOHwWiIjwFJDH+svbVCqXBkUKUAFqEy YGTqQag8awGyRocermWGuUYgPIYi/oq/rt6yr4FpWUMC1nIoG+/NafOLHlENQoji7CN3 X/tUTTqFFtKQEOht6bVINTE47Dvo62t6noyGkgK3EFlV09nrnch5551dNY1pci/fGZuU mxVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727089211; x=1727694011; 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=0J8gDMucjxpOg+RLl5wRybpqYOL20vywcDEytKDdvEc=; b=Vk60W3Q9CFoYHDopQOb/O+GksXqqE6KvzrWnjyELBPAJh3kQgIkFKSxk68mjxS7jUr i+6btTnG74HtAkttt30vP6+PzM9QigjIadCyvlUjKXJpoJ999jdd2kFf0RveeDFJgcMC v9jBhCtUa6gwMKF+TwfZgiEyXIBtJcwW2Cn8npAzHPHTiqDzZU6iRc1j7y4SW7C+auKI nfSXcM/RIOznedA94MkNAfFX3WXOA125Q0weUSqrIntXnVq1F2acKmyjaL8vldAH456j F8U5YVKf9XgGo/c5eS4QSDSvNsRCoc3wGNGoJnjT33pGSaJ2tnUWW170h5GqfVSzN2j+ tDwA== X-Forwarded-Encrypted: i=1; AJvYcCU3FzJKRQEAa/+GABl7Klv+BoyntHyCCqqly7HUZLOES7norOiwJ67cGRD5eKtu+BEyl4RE+UA30eIijU0=@vger.kernel.org, AJvYcCVuaCX8KZw6LchblAYYb3AS7dlZScf6l1b4o+HiJVT4UufjWFRoXufnv4yhiUE5tZCrZiexwUE2lrn2zsVV@vger.kernel.org, AJvYcCWDXzV8Fdx0XOeapuC+UwkDaZrj1g9O0EXtvWG0+Qrumxajd4XtqkLJSwi9/DAGvha444vIVdVG88Bk@vger.kernel.org, AJvYcCWZhXXw3t8smBs205GGBv5UjOlrNcr6AgeckwYI2bJSsU1FUnNIb3E0XUc9QNcR/CfQSmpSpZ5If04e@vger.kernel.org, AJvYcCXN9L+s6RkhifMt8qun94U+2ls8k7a3EMHbE+1cs1DdxP4zcp9/M/tdRQtlht/6Vy2AJl6IHzz9MfUk@vger.kernel.org X-Gm-Message-State: AOJu0Ywhv8g7R1xhSgLMGYiqju15CMXbsdTNvXG4L4Zg7GTvaP8731F1 +HS+7ce4WiddhN9HStfxOCqNDOJbH/ySf9yEIGjCtFJn3F6NEnEE X-Google-Smtp-Source: AGHT+IFeb78k1+laVLSiQw856wlmUQHHbPVCt0dUfiaaxlf+k4rQ9ERm4Xf6Ji92ZB1ddQNxoAu1uQ== X-Received: by 2002:a5d:4c44:0:b0:371:8319:4dcc with SMTP id ffacd0b85a97d-37a422520c3mr6639710f8f.2.1727089211311; Mon, 23 Sep 2024 04:00:11 -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-42e7afd7490sm97856615e9.28.2024.09.23.04.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:00:11 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , INAGAKI Hiroshi , Daniel Golle , Christian Brauner , Al Viro , Ming Lei , Li Lingfeng , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi Subject: [RFC PATCH 3/4] block: add support for partition table defined in OF Date: Mon, 23 Sep 2024 12:59:32 +0200 Message-ID: <20240923105937.4374-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240923105937.4374-1-ansuelsmth@gmail.com> References: <20240923105937.4374-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. The 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 or UFS devices in general. If this suffix is detected, "partitions-boot0" or "partitions-boot1" are used instead of the generic "partitions" Signed-off-by: Christian Marangi --- block/partitions/Kconfig | 8 ++++ block/partitions/Makefile | 1 + block/partitions/of.c | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 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/of.c b/block/partitions/of.c new file mode 100644 index 000000000000..1c420b7f53c0 --- /dev/null +++ b/block/partitions/of.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0 + +#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, + const char *disk_name) +{ + const char *node_name = "partitions"; + + /* Check if we are parsing boot0 or boot1 */ + 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 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); + + offset = of_read_number(reg, a_cells); + size = of_read_number(reg + a_cells, s_cells); + + put_partition(state, slot, offset, size); + + if (of_property_read_bool(pp, "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 = 1; + + disk_np = of_node_get(ddev->parent->of_node); + if (!disk_np) + return 0; + + partitions_np = get_partitions_node(disk_np, + state->disk->disk_name); + if (!partitions_np) + return 0; + + for_each_child_of_node(partitions_np, np) { + if (slot >= state->limit) + return -1; + + add_of_partition(state, slot, np); + + slot++; + } + + strlcat(state->pp_buf, "\n", PAGE_SIZE); + + return 1; +} From patchwork Mon Sep 23 10:59:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13809505 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 1F9A7199234; Mon, 23 Sep 2024 11:00:14 +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=1727089216; cv=none; b=ETeyr9C6saBd7E92zFMkSBR23ngfwz6tXSv0SbsFVoNQJ+xui6Y27ISQ9GFJRgyxGjgOhmC8DQR3bRhx/R5vx7ZKjyS9Y7rfm+kaw2M8FnLWsW+4QIYfqVotUjdROZ0ZVgUqIcxqSbisMdJFMWLNuH/63/FucGfjpyyKD3Rs2DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727089216; c=relaxed/simple; bh=WK2gxePyJ3COI9wVgLo2wfO2u0lNfIo8LDzjMGUNyDE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9gS81rcQQDVDmhQciaOgY5AGxiRaa46c86PE/DTFt7DOFfTvLDdCbIQEUNTY+vQASNZqL8P5w10agKiatOtEvcu/RKXL+4VGBnvLFibvNRBq7+ZzGfuxWt+Yg0wh7qcMW4PmH+NLDcn9e7tu2OG+E/FKglZuxJlgli0pNPQ7JM= 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=V1b8jcNU; 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="V1b8jcNU" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42cae6bb895so41854175e9.1; Mon, 23 Sep 2024 04:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727089213; x=1727694013; 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=nUqmFP2QzVpf7LDbD5h6EoX7C93mpfwdZpjgGxZ7JB0=; b=V1b8jcNUQbo/A/dyYzcKtqpdxKRsyu6STfSSZpxNJliqLWtOsgYwEQ0B+UA3X+bS53 CjGm1pbpeh9gjIP2GoJjL9r5bBVRd3ShyCgSiOs0MHZvn8iZJJCMED/WqgpQOXaRsdz2 EizsfT1qX+qITec/r1HssVVqTqHgjTQ/0WOdvtVrfir0RcO3rI/rIUi/lb809gyduVv6 +w3ho7ijLoHNlCHMuQKqZhlMF/jZCLodzlTCJJcW+efZXf9Epof0DEW+5Oi/CVFRf/r8 dhB9Eb6g8pB1zRYK4WVBCqIMNqP3iqB22B2gp6NhP3D0IOPHyGyh88u8foUfl/U8TWwf 8lTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727089213; x=1727694013; 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=nUqmFP2QzVpf7LDbD5h6EoX7C93mpfwdZpjgGxZ7JB0=; b=ALbf9DugoGxInT2SfKE1akw9UrQhWtLkLuk+iOdqYFSuIFBJh8lHzZiqjvz33fwr58 J21iBtdDorxtUDsKMgwyIQoZ0KjMwYZCV4vliVl3VCU2vp6N6u6OKtICQYmSWW8ywF+4 kIGxnFgSWWXNPklL7O74oin/Ljb0QsgvgaIY7I95YLFardmYuoAWiF2/owBCl2zw8Xpm G3bZXULGjxQkWUqWRwIpTGiDa5Uuy5OZfciMrg1KB6uMYtcFW3CyNd/RDKfCSH5isE4j TbM7+ECLVjVIrN6/O/nsoLOvuwk+IRQ5rF/sHaQf83MgVkfSWYoNNLMIVY1RTt2yphIk JFIw== X-Forwarded-Encrypted: i=1; AJvYcCUNl0PG1An1JJIW4UskACyWWo12Kou9dvkkqemkyCQH79oine6vBEwRKWIVyuKcZtQlBncrBTktJBKpgaKA@vger.kernel.org, AJvYcCVbCcXVNdzqBe3fVNrU8gS7bAwJXT/yeQqkXJIuEE9E6kXdZRFyzwSdhzf2OfHRD68Koo6DUAP/AsrC@vger.kernel.org, AJvYcCVqDcctbDN1tVNI/kMxeTh+vGHEPsYy0BVBwH7KHrCX/N+UbVp8V3o6FX0qSVOWX5fDF+dIDHy0XSGHkU8=@vger.kernel.org, AJvYcCW+UCyU0D43Wdj0CnOL3zo4PfQAGyLEwb2moNVoUo5BxiXi/SnNGEJt+QSY/qAOI5lL+lSCs4nssVLi@vger.kernel.org, AJvYcCXhZ8Ij6+qLX966RDNVVjBdwszgxvuPwYPpNrrGlMbvz376qxWEV/B3fsbgW/tMP7RsDoUgwgfSofMG@vger.kernel.org X-Gm-Message-State: AOJu0YxcaJEOMlJQn/0Kh9SEx3rtEN7QEvCkuULj6BieICzSaWgs7YfN lAI3PylF4mZJslIoj4adC9pD4q6j4uLGi43t7r7vnS2UQ2gU3C0K X-Google-Smtp-Source: AGHT+IHCSD/ALgIwBZ5s3Hy9r99p7T8tE7frQFItu74MHzu4oqQCqGEDZBKVq8n6KYGDunFNzIIAfw== X-Received: by 2002:a7b:cb8f:0:b0:42c:c003:edd1 with SMTP id 5b1f17b1804b1-42e7fa8229dmr57296115e9.10.1727089213273; Mon, 23 Sep 2024 04:00:13 -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-42e7afd7490sm97856615e9.28.2024.09.23.04.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:00:12 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , INAGAKI Hiroshi , Daniel Golle , Christian Brauner , Al Viro , Ming Lei , Li Lingfeng , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi Subject: [RFC PATCH 4/4] dt-bindings: mmc: Document support for partition table in mmc-card Date: Mon, 23 Sep 2024 12:59:33 +0200 Message-ID: <20240923105937.4374-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240923105937.4374-1-ansuelsmth@gmail.com> References: <20240923105937.4374-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. eMMC provide a generic disk for user data and if supported also provide one or 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 | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.yaml b/Documentation/devicetree/bindings/mmc/mmc-card.yaml index fd347126449a..fab9fa5c170a 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,48 @@ properties: Use this to indicate that the mmc-card has a broken hpi implementation, and that hpi should not be used. + "#address-cells": true + + "#size-cells": true + +patternProperties: + "^partitions(-boot[01])?$": + type: object + + properties: + "#address-cells": true + + "#size-cells": true + + patternProperties: + "@[0-9a-f]+$": + type: object + + 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 + + required: + - reg + - label + + additionalProperties: false + + additionalProperties: false + required: - compatible - reg @@ -42,6 +88,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 0x10000>; /* 32 MB */ + }; + + partition@3400 { + label = "rootfs"; + reg = <0x3400 0x200000>; /* 1GB */ + }; + }; + + partitions-boot0 { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bl"; + reg = <0x0 0x10000>; /* 32MB */ + read-only; + }; + }; }; };