From patchwork Fri Mar 6 02:12:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 211151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48D43C3F2D1 for ; Fri, 6 Mar 2020 02:13:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D72D2073D for ; Fri, 6 Mar 2020 02:13:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GCoNJHXM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbgCFCNG (ORCPT ); Thu, 5 Mar 2020 21:13:06 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46486 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbgCFCNE (ORCPT ); Thu, 5 Mar 2020 21:13:04 -0500 Received: by mail-lf1-f68.google.com with SMTP id v6so559696lfo.13; Thu, 05 Mar 2020 18:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kWAeNpBn6fpU/PQ3w5gvOGDJx2Ia8b1U9luMqpJSJvQ=; b=GCoNJHXMgArvxZ2kM/SXnSPoe6CuzS1zwwvfEYI1KlFYLoorrkITULJUx3Bh9GbnRX VIRRkVVr7K9gbsfOJswpMD6cS20enbneC52QYoovNurXUspOU/zpy3asyICNHQ1ArnVB fSBXH3nwDbRCJLt+hq9KcomdYHcWTkThHIKiugDQOvkTSmecJgx2a3mbNx2CrhYXnl76 Bo/wWyDdQY2WTxgi/sAGjsQRRw8W/2ERuIUMiFcYZBPPD3egIen+S1TjNkjTFvYpOcD+ Xav6wj7i0tGs4vmtA7Wt9Wz9/5U94HQQb44WriLSfgMqV/LubpewdG5Emy+RmwRK8eUC 0YxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kWAeNpBn6fpU/PQ3w5gvOGDJx2Ia8b1U9luMqpJSJvQ=; b=MtrofvkbVKly0gah2Z5vp1HKxq0Wc+2bOVA/SRV1t6OnnuZ9ikN25FYFB9BGzk1vJx xQH3kdiOa79dKe0SGyvu418CGiy0fojKPZrkKqA50mHHB0Vrm7OZmltmIXcrrR3/3DRD ubI0sHSEZ33V8j/nokMDu9nSlQy1047HxUyUkyX0ctCEKKPCIv7XYqNnvHQBr7SoXNu/ 3FB5h2tcHW5Xl6f6Uk7UCu02XJhaCBslh9DLSaCkFeCdXFrGW1js3RL/DwgWD1YcJ7aX sM3aTWmQUcwgoNl2WHiqPKg92iluNdTa0opPF+lynQNXl/a9i5OJD/X40/EXsU0rzZ1c 02Ww== X-Gm-Message-State: ANhLgQ1GOXE0oEbAUkImTfEWTsA9SZ/99dF8jQYa4Fe4W8llVwsZFxoX /MvXsrJugPUIa2QMpKTv/QU= X-Google-Smtp-Source: ADFU+vsi8TcyLKDcJbRMBaRh8lMXYw471TYJmJyUORBjo/b50BvSewNmK3EH0JfzbLyyIuq3k9qLVA== X-Received: by 2002:a05:6512:3044:: with SMTP id b4mr435202lfb.10.1583460780575; Thu, 05 Mar 2020 18:13:00 -0800 (PST) Received: from localhost.localdomain (94-29-39-224.dynamic.spd-mgts.ru. [94.29.39.224]) by smtp.gmail.com with ESMTPSA id l11sm10592772lfg.87.2020.03.05.18.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 18:13:00 -0800 (PST) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Andrey Danin , Gilles Grandou , Ryan Grachek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] mmc: block: Add mmc_bdev_to_card() helper Date: Fri, 6 Mar 2020 05:12:14 +0300 Message-Id: <20200306021220.22097-3-digetx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200306021220.22097-1-digetx@gmail.com> References: <20200306021220.22097-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org NVIDIA Tegra Partition Table takes into account MMC card's BOOT_SIZE_MULT parameter, and thus, the partition parser needs to retrieve that EXT_CSD value from the block device. There are also some other parts of struct mmc_card that are needed for the partition parser in order to calculate the eMMC offset and verify different things. This patch introduces new helper which takes block device for the input argument and returns the corresponding MMC card. Signed-off-by: Dmitry Osipenko --- drivers/mmc/core/block.c | 15 +++++++++++++++ include/linux/mmc/blkdev.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 include/linux/mmc/blkdev.h diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 7634894df853..36d84a8e182c 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -306,6 +307,20 @@ static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr, return ret; } +struct mmc_card *mmc_bdev_to_card(struct block_device *bdev) +{ + struct mmc_blk_data *md; + + if (bdev->bd_disk->major != MMC_BLOCK_MAJOR) + return NULL; + + md = mmc_blk_get(bdev->bd_disk); + if (!md) + return NULL; + + return md->queue.card; +} + static int mmc_blk_open(struct block_device *bdev, fmode_t mode) { struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); diff --git a/include/linux/mmc/blkdev.h b/include/linux/mmc/blkdev.h new file mode 100644 index 000000000000..67608c58de70 --- /dev/null +++ b/include/linux/mmc/blkdev.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * linux/include/linux/mmc/blkdev.h + */ +#ifndef LINUX_MMC_BLOCK_DEVICE_H +#define LINUX_MMC_BLOCK_DEVICE_H + +struct block_device; +struct mmc_card; + +struct mmc_card *mmc_bdev_to_card(struct block_device *bdev); + +#endif /* LINUX_MMC_BLOCK_DEVICE_H */ From patchwork Fri Mar 6 02:12:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 211148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CC93C3F2D2 for ; Fri, 6 Mar 2020 02:13:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 719FA2073D for ; Fri, 6 Mar 2020 02:13:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jx7+ypvb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726998AbgCFCNH (ORCPT ); Thu, 5 Mar 2020 21:13:07 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36514 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbgCFCNG (ORCPT ); Thu, 5 Mar 2020 21:13:06 -0500 Received: by mail-lf1-f66.google.com with SMTP id s1so610702lfd.3; Thu, 05 Mar 2020 18:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YN6wlr+SxSHAMt4dIT8x49SccG7CxZ44xau7TZEGR7U=; b=Jx7+ypvbC80brAY/Gha594a/i/lBbvNebyh9jVnMeiq4NZ0467KVdUQQbUlcBMgq+E HvN2WEwpZD+UNr9EUJwxcT3O1+0uIASmmGmz0mFpxy+9K4PY4udqTIciQ/pdj4oUL64r yNIvhBU+SIa6dXMFV7Sm5wukgH95gp3hizlZIT4Tz8meBVMv7nr2jaS7DirywMhzxyKQ JE3MBpS8HIWdEdg05hCFFtn5CHp7bRkXhHLMH5/txcQl6TRg8C6OvLmp0L+B5dYGhYvN YDXgzajsH+OK/k1qI29x53wtaKwNBBgPqqRUNN9C76uVPLUUqf3DLWpooHE55TdBVqwe veHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YN6wlr+SxSHAMt4dIT8x49SccG7CxZ44xau7TZEGR7U=; b=B9bE9BNxChwES5QzNRm8Ulhkk4N/EExF+5GLQpslt+4MlgYdQfKWnuhigzXAl3WUvT qNHEeKvvEH9NtQXmTs8u2OrEaMOJfppGxJ32zyCZBHVacGm14upZMxQX9Cx3ak3lRYHD BPDxHjuHjVzLv2hNWvBEuLeXMrTXlqhWTGp+sapvTbnTgvi2V+4Hc96Cvs3rKhJkf8xi tPcZx+zZa8Yp5zsnSWD6lf60JyhHniO78xDBxUU+SS6WsxeB2D/H8iURBUTdTUPdEpVX 9Y5MrQm+cMK3YKKMw2oGVre5xh8K6+20jDB8TcMjQQ1Q6ppX7U61tL1DlMvi3Kgo8e7x wgDA== X-Gm-Message-State: ANhLgQ2SY1fTAeSyIrkyKuDfDNgOYw/NtPFV1qzJDgO1ylcPoz7zgs6O F29wPl3oirwx7ZyKQ62tXQ4= X-Google-Smtp-Source: ADFU+vvTceBXi8aJvLfj04kqqObBlzYK7DQWM7JZXu8umtbwBSvF3gK3rosGoh7gVG/pUB+B4TF52w== X-Received: by 2002:ac2:4199:: with SMTP id z25mr416158lfh.90.1583460784112; Thu, 05 Mar 2020 18:13:04 -0800 (PST) Received: from localhost.localdomain (94-29-39-224.dynamic.spd-mgts.ru. [94.29.39.224]) by smtp.gmail.com with ESMTPSA id l11sm10592772lfg.87.2020.03.05.18.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 18:13:03 -0800 (PST) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Andrey Danin , Gilles Grandou , Ryan Grachek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] mmc: block: Add mmc_bdev_to_area_type() helper Date: Fri, 6 Mar 2020 05:12:17 +0300 Message-Id: <20200306021220.22097-6-digetx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200306021220.22097-1-digetx@gmail.com> References: <20200306021220.22097-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org NVIDIA Tegra Partition Table parser needs to know eMMC partition type in order to validate and parse partition table properly. This patch adds new mmc_bdev_to_area_type() helper which takes block device for the input and returns a corresponding MMC card partition type. This allows tegra-partition parser to distinguish boot eMMC partition from the main eMMC partition. Signed-off-by: Dmitry Osipenko --- drivers/mmc/core/block.c | 16 ++++++++++++++++ include/linux/mmc/blkdev.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 2cee57c7388d..ec69b613ee92 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -337,6 +337,22 @@ int mmc_bdev_to_part_type(struct block_device *bdev) return md->part_type; } +int mmc_bdev_to_area_type(struct block_device *bdev) +{ + struct mmc_blk_data *md; + struct mmc_card *card; + + card = mmc_bdev_to_card(bdev); + if (!card) + return -EINVAL; + + md = mmc_blk_get(bdev->bd_disk); + if (!md) + return -EINVAL; + + return md->area_type; +} + static int mmc_blk_open(struct block_device *bdev, fmode_t mode) { struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); diff --git a/include/linux/mmc/blkdev.h b/include/linux/mmc/blkdev.h index 24e73ac02b4b..5fa5ef35ac25 100644 --- a/include/linux/mmc/blkdev.h +++ b/include/linux/mmc/blkdev.h @@ -10,5 +10,6 @@ struct mmc_card; struct mmc_card *mmc_bdev_to_card(struct block_device *bdev); int mmc_bdev_to_part_type(struct block_device *bdev); +int mmc_bdev_to_area_type(struct block_device *bdev); #endif /* LINUX_MMC_BLOCK_DEVICE_H */ From patchwork Fri Mar 6 02:12:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 211149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1615DC3F2D2 for ; Fri, 6 Mar 2020 02:13:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB51C208C3 for ; Fri, 6 Mar 2020 02:13:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BrQ3TxdT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbgCFCNX (ORCPT ); Thu, 5 Mar 2020 21:13:23 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:33239 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbgCFCNI (ORCPT ); Thu, 5 Mar 2020 21:13:08 -0500 Received: by mail-lf1-f65.google.com with SMTP id c20so630224lfb.0; Thu, 05 Mar 2020 18:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MD6xGZ4xORI+tNtNZZDwyKjUfBMMQlzk74IcvklWY7A=; b=BrQ3TxdTprBb4eSSxaLqFHnbM/+U/tPxgTJ0glnciTf2irzC04pjVRWt7vvn4hbJqz R4F6J6rcZ7+l+ykEC+mQ3kO+Q3CoD6BxRy5tdG+YJYtrC3FOTCGkAF1WHNv/MXaqYpE6 VhE4e63Mrgm5Mtkfc69IJf9BRDMbRwN7RiM8jYSgA4+exS4J9/lb1RdC7JOe6oAj0b3X O+PPZl4Dccgdc63LBnCBlkjQN6oquHz6yX0hJGkPAy1XB+L0dF+oiWnH5UFLDwRpTc4m g0WGUL8HBLYuLueiE8jA2FyCiWw17MvCexPCeywvHs8B0tPYFjiStQZEuadWjYdBnW2R nOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MD6xGZ4xORI+tNtNZZDwyKjUfBMMQlzk74IcvklWY7A=; b=GyYC1LiWJttDATKZbSfKPi4Rs1yVq+hjf21xhfRxOG5uLCUgYbbYxPw0aKaobIHNoT vWq9FbZXZKLzjCs6LVuNJx0aKmBc5PhbeswkIkIB6iTWukyZaMvtbUx8y/d7KK04YKpq FX7BPby1bMddElQEKxm048RY1Qd/+HXHCc0M07AaRiyfzCkqEaysjx8l74Dc13SVV1mw QZI4kZDqG64oEGnB7wBpIeat8RR0RkxXJSCeh77I5Wi1qvZx2oTK8pwTkOrUixBg3Tk9 AulSTpkG+JJ/WRLTxlgxOTh8sPyF/lF7TxNinL+kgElG400/mIQjCYIlHrGVpSmsV1a/ 1Xpg== X-Gm-Message-State: ANhLgQ0kHH3abbh/zmfHm7DGJn4OqI3OvlZgN+uyu5v9NxcF/cgAP/oP K82or6v7RvVa86mUwhOWtEk= X-Google-Smtp-Source: ADFU+vveYHEwu/jjmm9qd6Po2zGPfAIH8wer39yJagxuJWLIFc8zFnHZhdGONFQQjYKpeMQxDY9Fcg== X-Received: by 2002:a05:6512:203c:: with SMTP id s28mr404120lfs.117.1583460785364; Thu, 05 Mar 2020 18:13:05 -0800 (PST) Received: from localhost.localdomain (94-29-39-224.dynamic.spd-mgts.ru. [94.29.39.224]) by smtp.gmail.com with ESMTPSA id l11sm10592772lfg.87.2020.03.05.18.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 18:13:04 -0800 (PST) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Andrey Danin , Gilles Grandou , Ryan Grachek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] mmc: block: Add MMC_QUIRK_RESCAN_MAIN_BLKDEV Date: Fri, 6 Mar 2020 05:12:18 +0300 Message-Id: <20200306021220.22097-7-digetx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200306021220.22097-1-digetx@gmail.com> References: <20200306021220.22097-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org NVIDIA Tegra Partition Table location isn't restricted by the main eMMC partition. This patch introduces new MMC-card quirk which is needed by some NVIDIA Tegra devices in order to set up partition table if it is stored on a eMMC boot partition. The tegra-partition parser will read out FS partition table from the eMMC boot partition and stash it for the main eMMC partition. In this case block device of the main eMMC partition needs to be re-scanned in order to assign the stashed partition table to the main MMC block device by tegra-partition parser. This patch adds new MMC card flag that is applied by tegra-partition parser to the scanned MMC card if partition table is found on a boot eMMC partition. This flag tells MMC_BLOCK core that main MMC partition needs to be re-scanned once all block devices of the MMC card are instantiated. Signed-off-by: Dmitry Osipenko --- drivers/mmc/core/block.c | 31 +++++++++++++++++++++++++++++++ include/linux/mmc/card.h | 1 + 2 files changed, 32 insertions(+) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index ec69b613ee92..2c2bec114fd6 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2955,6 +2955,27 @@ static void mmc_blk_remove_debugfs(struct mmc_card *card, #endif /* CONFIG_DEBUG_FS */ +static int mmc_blk_rescan_disk(struct mmc_blk_data *md) +{ + struct block_device *bdev; + + bdev = blkdev_get_by_dev(disk_devt(md->disk), FMODE_READ | FMODE_EXCL, + md); + if (IS_ERR(bdev)) { + pr_err("%s: %s: failed to get block device\n", + __func__, md->disk->disk_name); + return PTR_ERR(bdev); + } + + mutex_lock(&bdev->bd_mutex); + bdev_disk_changed(bdev, false); + mutex_unlock(&bdev->bd_mutex); + + blkdev_put(bdev, FMODE_READ | FMODE_EXCL); + + return 0; +} + static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; @@ -2998,6 +3019,16 @@ static int mmc_blk_probe(struct mmc_card *card) goto out; } + /* + * Quirk for NVIDIA Tegra devices that store FS partition table + * on a boot partition. Tegra-partition scanner found partition + * table on a boot MMC partition and stashed it for the main MMC + * partition if MMC_QUIRK_RESCAN_MAIN_BLKDEV is set, and thus, + * the main partition needs to be re-scanned. + */ + if (card->quirks & MMC_QUIRK_RESCAN_MAIN_BLKDEV) + mmc_blk_rescan_disk(md); + /* Add two debugfs entries */ mmc_blk_add_debugfs(card, md); diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 90b1d83ce675..550d50e57cc4 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -270,6 +270,7 @@ struct mmc_card { #define MMC_QUIRK_BROKEN_IRQ_POLLING (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */ #define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */ #define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */ +#define MMC_QUIRK_RESCAN_MAIN_BLKDEV (1<<14) /* Main partition needs to be re-scanned after instantiating all partitions */ bool reenable_cmdq; /* Re-enable Command Queue */ From patchwork Fri Mar 6 02:12:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 211150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C796C3F2D8 for ; Fri, 6 Mar 2020 02:13:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 762392073D for ; Fri, 6 Mar 2020 02:13:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CDA7zUNF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbgCFCNL (ORCPT ); Thu, 5 Mar 2020 21:13:11 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37954 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbgCFCNK (ORCPT ); Thu, 5 Mar 2020 21:13:10 -0500 Received: by mail-lj1-f194.google.com with SMTP id w1so525345ljh.5; Thu, 05 Mar 2020 18:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wabg51D9gVFdZmwGILk+PNoiwB7CSCBLaOu5bBJA6MQ=; b=CDA7zUNFYgBiMnVeXxblPUiuodOsV1slXflncfVLlsmh7On/RMeAS3ws4jEY2cT7Z/ LLUcZZ9zZGuTulKxYJXi30qqPuT12NApmI+yO3fco89K2UsjM92N5E0LrA6IIlNUofwh 3/s7DZgg+M0UqE6pQ68ZWohEZr3qk3WarWZG2HkMwDICffxjUlQByoBx+68vTVP6uiRV kOmCs+u62hms+qw/d/VpZ4Sw5aS15Ibx6u+O+zjZOCbs0fjJWTA0zdwT+I+8ry4QwmHO 1N7hkNMdWSAHMFZ80p0p9g88rJNextyYs76fyj8WuUsRNrfx3D9JMCWy7lLSyb9OMTzz XBcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wabg51D9gVFdZmwGILk+PNoiwB7CSCBLaOu5bBJA6MQ=; b=GBtzKyG7MW1y76kjcJhbi2R05T2PluvWzLkRep8+qE4TJG5SU+NLNntJlZHMyP0WbJ 3GFNIkXWaxG95q0xj4vYNoPDbLFxT4qBrs0AYcAotcTPJvdHZuX+T4202Gy4E+rDINQ7 8llmb/p0RINP+daIaBmYo424ewIWi/FR0S7f5tSnWXMCXgTc4rxMsLZa6Lwvj4BVbckW mFOePszh4V9xGIaSQ8CdMcM721eDF90HWucHtyqNPl8aLZfMwS6t2ZJ2WBnRQRCOxsuj emRjOPi5wZdZrWxhUJCczy5na3V5O9prZZ0aZ3vONIBP3jgzhe7NMun19RqyW5Ti08pX KyXw== X-Gm-Message-State: ANhLgQ2auxsbBlwYO3q8WWzg9Wpw9djNhwq5FUfUKAE+BneDXIpAES35 v9VJ30dP2Ibv7jRlUffXYnw= X-Google-Smtp-Source: ADFU+vvoPGanJEdTBlfo3M7P+8VNt4spDbAkZRi5yTmd5IEWTE+o3rxEJ+Grhf4f+K/dPqWnou0NcQ== X-Received: by 2002:a2e:b78e:: with SMTP id n14mr564850ljo.269.1583460786531; Thu, 05 Mar 2020 18:13:06 -0800 (PST) Received: from localhost.localdomain (94-29-39-224.dynamic.spd-mgts.ru. [94.29.39.224]) by smtp.gmail.com with ESMTPSA id l11sm10592772lfg.87.2020.03.05.18.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 18:13:06 -0800 (PST) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Andrey Danin , Gilles Grandou , Ryan Grachek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] mmc: block: Enable partition-table scanning for boot partitions Date: Fri, 6 Mar 2020 05:12:19 +0300 Message-Id: <20200306021220.22097-8-digetx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200306021220.22097-1-digetx@gmail.com> References: <20200306021220.22097-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Some NVIDIA Tegra devices store partition table on a boot eMMC partition, and thus, boot partitions need to be scanned. This patch enables scanning of the boot MMC partitions. Please note that boot partitions will be scanned-only, i.e. the scanned boot partitions will be kept hidden. Signed-off-by: Dmitry Osipenko --- drivers/mmc/core/block.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 2c2bec114fd6..b834c830e19a 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2410,9 +2410,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, md->parent = parent; set_disk_ro(md->disk, md->read_only || default_ro); md->disk->flags = GENHD_FL_EXT_DEVT; + if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT)) - md->disk->flags |= GENHD_FL_NO_PART_SCAN - | GENHD_FL_SUPPRESS_PARTITION_INFO; + md->disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; + + if (area_type & MMC_BLK_DATA_AREA_RPMB) + md->disk->flags |= GENHD_FL_NO_PART_SCAN; /* * As discussed on lkml, GENHD_FL_REMOVABLE should: