From d1f91702ae34dc6c3dabc7d45537935adeca828a Mon Sep 17 00:00:00 2001 From: liuhuan Date: Wed, 30 Jun 2021 20:14:35 +0800 Subject: [PATCH] fixed the MMC can not be partitioned --- block/partitions/Kconfig | 11 +++++++++++ block/partitions/Makefile | 1 + block/partitions/check.c | 5 +++++ drivers/mmc/core/block.c | 10 ++++++++-- fs/block_dev.c | 10 +++++++--- include/linux/genhd.h | 4 +++- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/block/partitions/Kconfig b/block/partitions/Kconfig index 37b9710cc80a5..c37a810db8673 100644 --- a/block/partitions/Kconfig +++ b/block/partitions/Kconfig @@ -262,6 +262,17 @@ config SYSV68_PARTITION sysv68). Otherwise, say N. +config RK_PARTITION + bool "Rockchip partition table support" if PARTITION_ADVANCED + default y if ARCH_ROCKCHIP + ---help--- + Like most systems, Rockchip use its own hard disk partition table + format, incompatible with all others. Say Y here if you would like + to be able to read the hard disk partition table format used by + Rockchip SoCs inside machines with eMMC as main storage disk. + Otherwise, say N. + + config CMDLINE_PARTITION bool "Command line partition support" if PARTITION_ADVANCED select BLK_CMDLINE_PARSER diff --git a/block/partitions/Makefile b/block/partitions/Makefile index 2f276b677c817..83bbf1d25d091 100644 --- a/block/partitions/Makefile +++ b/block/partitions/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o obj-$(CONFIG_AMIGA_PARTITION) += amiga.o obj-$(CONFIG_ATARI_PARTITION) += atari.o obj-$(CONFIG_AIX_PARTITION) += aix.o +obj-$(CONFIG_RK_PARTITION) += rk.o obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o obj-$(CONFIG_MAC_PARTITION) += mac.o obj-$(CONFIG_LDM_PARTITION) += ldm.o diff --git a/block/partitions/check.c b/block/partitions/check.c index ffe408fead0cd..0686874f5118b 100644 --- a/block/partitions/check.c +++ b/block/partitions/check.c @@ -36,6 +36,7 @@ #include "karma.h" #include "sysv68.h" #include "cmdline.h" +#include "rk.h" int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ @@ -67,6 +68,10 @@ static int (*check_part[])(struct parsed_partitions *) = { adfspart_check_ADFS, #endif +#ifdef CONFIG_RK_PARTITION + rkpart_partition, +#endif + #ifdef CONFIG_CMDLINE_PARTITION cmdline_partition, #endif diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index f93e4f9367561..13aa2414ac0b6 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2914,8 +2914,14 @@ static int mmc_blk_probe(struct mmc_card *card) dev_set_drvdata(&card->dev, md); #if IS_ENABLED(CONFIG_MMC_DW_ROCKCHIP) || IS_ENABLED(CONFIG_MMC_SDHCI_OF_ARASAN) - if (card->host->restrict_caps & RESTRICT_CARD_TYPE_EMMC) - this_card = card; + /*if (card->host->restrict_caps & RESTRICT_CARD_TYPE_EMMC) + this_card = card;*/ + if (card->host->restrict_caps & RESTRICT_CARD_TYPE_EMMC) { + this_card = card; + md->disk->is_rk_disk = true; + } else { + md->disk->is_rk_disk = false; + } #endif if (mmc_add_disk(md)) diff --git a/fs/block_dev.c b/fs/block_dev.c index 800f666c75a95..6e763333b25e9 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1519,9 +1519,13 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) * The latter is necessary to prevent ghost * partitions on a removed medium. */ - if (bdev->bd_invalidated && - (!ret || ret == -ENOMEDIUM)) - bdev_disk_changed(bdev, ret == -ENOMEDIUM); + if (bdev->bd_invalidated){ + if (!ret){ + rescan_partitions(disk, bdev); + } + else if (ret == -ENOMEDIUM) + bdev_disk_changed(bdev, ret == -ENOMEDIUM); + } if (ret) goto out_clear; diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 48770a0704cce..c645bb2e03a54 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -206,7 +206,9 @@ struct gendisk { const struct block_device_operations *fops; struct request_queue *queue; void *private_data; - + + /* Flag of rockchip specific disk: eMMC/eSD, NVMe, etc. */ + bool is_rk_disk; int flags; struct rw_semaphore lookup_sem; struct kobject *slave_dir;