mmc: Support non-standard gpt_sector cmdline parameter

Add support for the gpt_sector cmdline parameter which will be used
for looking up GPT entry on internal eMMC storage of NVIDIA Tegra20+
devices. This parameter is used by a stock downstream bootloader of
Android devices.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
This commit is contained in:
Dmitry Osipenko
2021-07-22 21:19:59 +03:00
committed by Thomas Makin
parent abeb79e303
commit fa5772ad55
2 changed files with 27 additions and 0 deletions

View File

@@ -98,6 +98,15 @@ static int force_gpt;
static int __init
force_gpt_fn(char *str)
{
/*
* This check allows to properly parse cmdline variants like
* "gpt gpt_sector=<sector>" and "gpt_sector=<sector> gpt" since
* "gpt" overlaps with the "gpt_sector=", see tegra_gpt_sector_fn().
* The argument is absent for a boolean cmdline option.
*/
if (strlen(str))
return 0;
force_gpt = 1;
return 1;
}

View File

@@ -2169,6 +2169,19 @@ int mmc_detect_card_removed(struct mmc_host *host)
}
EXPORT_SYMBOL(mmc_detect_card_removed);
/*
* This allows a kernel command line option 'gpt_sector=<sector>' to
* enable GPT header lookup at a non-standard location. This option
* is provided to kernel by NVIDIA's proprietary bootloader.
*/
static sector_t cmdline_gpt_sector;
static int __init cmdline_gpt_sector_fn(char *str)
{
WARN_ON(kstrtoull(str, 10, &cmdline_gpt_sector) < 0);
return 1;
}
__setup("gpt_sector=", cmdline_gpt_sector_fn);
int mmc_card_alternative_gpt_sector(struct mmc_card *card, sector_t *gpt_sector)
{
unsigned int boot_sectors_num;
@@ -2183,6 +2196,11 @@ int mmc_card_alternative_gpt_sector(struct mmc_card *card, sector_t *gpt_sector)
mmc_card_is_removable(card->host))
return -ENOENT;
if (cmdline_gpt_sector) {
*gpt_sector = cmdline_gpt_sector;
return 0;
}
/*
* eMMC storage has two special boot partitions in addition to the
* main one. NVIDIA's bootloader linearizes eMMC boot0->boot1->main