mmc: add a cap and a quirk
Adrian Hunter
maintainercover mmc: add a cap and a quirk
Hi
Here are patches for Medfield to allow the use of high-capacity erase size and to allow the SDIO host controller to be off when the card is kept on during suspend - replacing the earlier patch "mmc: sdhci: always reset all during resume"
Adrian Hunter (4):
mmc: core: add high-capacity erase size capability flag
mmc: sdhci-pci: select HC erase size for Medfield eMMC
mmc: sdhci: add quirk for keeping card power during suspend
mmc: sdhci-pci: add SDHCI_QUIRK2_HOST_OFF_CARD_ON for Medfield SDIO
drivers/mmc/core/mmc.c | 3 ++- drivers/mmc/host/sdhci-pci.c | 8 +++++++- drivers/mmc/host/sdhci.c | 13 +++++++++++-- include/linux/mmc/host.h | 1 + include/linux/mmc/sdhci.h | 2 ++ 5 files changed, 23 insertions(+), 4 deletions(-)
Regards
Adrian
Adrian Hunter
maintainerPATCH 1/4 mmc: core: add high-capacity erase size capability flag
Let drivers specify the use of high-capacity erase size.
--- drivers/mmc/core/mmc.c | 3 ++- include/linux/mmc/host.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/mmc/core/mmc.c +2 -1
@@ -949,7 +949,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,* If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF * bit. This bit will be lost every time after a reset or power off. */ -if (card->ext_csd.enhanced_area_en) { +if (card->ext_csd.enhanced_area_en || + (card->ext_csd.rev >=3 && (host->caps2 &MMC_CAP2_HC_ERASE_SZ ))) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_ERASE_GROUP_DEF ,1 , card->ext_csd.generic_cmd6_time);
include/linux/mmc/host.h +1 -0
@@ -258,6 +258,7 @@ struct mmc_host {#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ MMC_CAP2_HS200_1_2V_SDR)#define MMC_CAP2_BROKEN_VOLTAGE (1 << 7)/* Use the broken voltage */ +#define MMC_CAP2_HC_ERASE_SZ (1 << 8)/* High-capacity erase size */ mmc_pm_flag_t pm_caps;/* supported pm features */ unsigned int power_notify_type;
Signature · 1 line
1.7.6.4
Re: [PATCH 1/4] mmc: core: add high-capacity erase size capability flag
Quoted 13 lines · Adrian Hunter
Let drivers specify the use of high-capacity erase size.
Signed-off-by Adrian Hunter<[email protected]>--- drivers/mmc/core/mmc.c | 3 ++- include/linux/mmc/host.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)drivers/mmc/core/mmc.c +0
-0
drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host *host, u32 ocr, · line 953
Quoted 6 lines
drivers/mmc/core/mmc.c +2
-1@@ -949,7 +949,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,* If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF * bit. This bit will be lost every time after a reset or power off. */ -if (card->ext_csd.enhanced_area_en) { +if (card->ext_csd.enhanced_area_en || + (card->ext_csd.rev>=3 && (host->caps2&MMC_CAP2_HC_ERASE_SZ ))) {
This will default disable this feature. Is that what we want? Why the need to disable this at all?
Quoted 8 lines
drivers/mmc/core/mmc.c +0
-0err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_ERASE_GROUP_DEF ,1 , card->ext_csd.generic_cmd6_time);include/linux/mmc/host.h +0
-0
include/linux/mmc/host.h struct mmc_host { · line 264
Quoted 7 lines
include/linux/mmc/host.h +1
-0@@ -258,6 +258,7 @@ struct mmc_host {#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ MMC_CAP2_HS200_1_2V_SDR)#define MMC_CAP2_BROKEN_VOLTAGE (1<< 7)/* Use the broken voltage */ +#define MMC_CAP2_HC_ERASE_SZ (1<< 8)/* High-capacity erase size */ mmc_pm_flag_t pm_caps;/* supported pm features */ unsigned int power_notify_type;
Br
Ulf Hansson
Adrian Hunter
maintainerRe: [PATCH 1/4] mmc: core: add high-capacity erase size capability flag
Quoted 9 lines · Ulf Hansson
Quoted 8 lines · Adrian Hunter
Let drivers specify the use of high-capacity erase size.
Signed-off-by Adrian Hunter<[email protected]>--- drivers/mmc/core/mmc.c | 3 ++- include/linux/mmc/host.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
Quoted 14 lines
drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host *host, u32 ocr, · line 953
Quoted 11 lines
drivers/mmc/core/mmc.c +2
-1@@ -949,7 +949,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,* If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF * bit. This bit will be lost every time after a reset or power off. */ -if (card->ext_csd.enhanced_area_en) { +if (card->ext_csd.enhanced_area_en || + (card->ext_csd.rev>=3 && (host->caps2&MMC_CAP2_HC_ERASE_SZ ))) {This will default disable this feature. Is that what we want? Why the need to disable this at all?
It will change the erase group size and the write protect group size. That will cause breakage for anyone using write protect groups of a smaller size.
Quoted 20 lines
Quoted 9 lines
drivers/mmc/core/mmc.c +0
-0err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_ERASE_GROUP_DEF ,1 , card->ext_csd.generic_cmd6_time);include/linux/mmc/host.h +0
-0include/linux/mmc/host.h struct mmc_host { · line 264
Quoted 7 lines
include/linux/mmc/host.h +1
-0@@ -258,6 +258,7 @@ struct mmc_host {#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ MMC_CAP2_HS200_1_2V_SDR)#define MMC_CAP2_BROKEN_VOLTAGE (1<< 7)/* Use the broken voltage */ +#define MMC_CAP2_HC_ERASE_SZ (1<< 8)/* High-capacity erase size */ mmc_pm_flag_t pm_caps;/* supported pm features */ unsigned int power_notify_type;Br
Ulf Hansson
Re: [PATCH 1/4] mmc: core: add high-capacity erase size capability flag
In reply to Adrian HunterQuoted 3 lines · Adrian Hunter
Let drivers specify the use of high-capacity erase size.
Signed-off-by Adrian Hunter <[email protected]>
(...)
drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host *host, u32 ocr, · line 953
Quoted 7 lines
drivers/mmc/core/mmc.c +2
-1@@ -949,7 +949,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,* If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF * bit. This bit will be lost every time after a reset or power off. */ - if (card->ext_csd.enhanced_area_en) { + if (card->ext_csd.enhanced_area_en || + (card->ext_csd.rev >= 3 && (host->caps2 & MMC_CAP2_HC_ERASE_SZ))) {
It looks like there is a bug fix hidden inside this patch, is it not? The comparison for card->ext_csd.rev >= 3 was not there before, and looks like it's fixing something and should go into stable even, is that correct?
Yours,
Linus Walleij
Adrian Hunter
maintainerRe: [PATCH 1/4] mmc: core: add high-capacity erase size capability flag
Quoted 6 lines · Linus Walleij
Quoted 3 lines · Adrian Hunter
Let drivers specify the use of high-capacity erase size.
Signed-off-by Adrian Hunter <[email protected]>(...)
Quoted 12 lines
drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host *host, u32 ocr, · line 953
Quoted 7 lines
drivers/mmc/core/mmc.c +2
-1@@ -949,7 +949,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,* If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF * bit. This bit will be lost every time after a reset or power off. */ -if (card->ext_csd.enhanced_area_en) { +if (card->ext_csd.enhanced_area_en || + (card->ext_csd.rev >=3 && (host->caps2 &MMC_CAP2_HC_ERASE_SZ ))) {It looks like there is a bug fix hidden inside this patch, is it not? The comparison for
card->ext_csd.rev>= 3 was not there before, and looks like it's fixing something and should go into stable even, is that correct?
No because because enhanced areas were added in v4.4 so "card->ext_csd.enhanced_area_en" implies "card->ext_csd.rev >= 4"
High-capacity erase size was added in v4.3 so "card->ext_csd.rev >= 3" is parenthesised with "(host->caps2 & MMC_CAP2_HC_ERASE_SZ)"
Adrian Hunter
maintainerPATCH 2/4 mmc: sdhci-pci: select HC erase size for Medfield eMMC
In reply to Adrian Hunter--- drivers/mmc/host/sdhci-pci.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci-pci.c +2 -1
@@ -244,7 +244,8 @@ static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)static int mfd_emmc_probe_slot (struct sdhci_pci_slot *slot) { slot->host->mmc->caps |=MMC_CAP_8_BIT_DATA |MMC_CAP_NONREMOVABLE ; - slot->host->mmc->caps2 =MMC_CAP2_BOOTPART_NOACC ; + slot->host->mmc->caps2 |=MMC_CAP2_BOOTPART_NOACC | +MMC_CAP2_HC_ERASE_SZ ;return 0 ; }
Signature · 1 line
1.7.6.4
Adrian Hunter
maintainerPATCH 3/4 mmc: sdhci: add quirk for keeping card power during suspend
In reply to Adrian HunterAdd quirk SDHCI_QUIRK2_HOST_OFF_CARD_ON to cater for the case when the card keeps power during suspend but the host controller does not i.e. the card power is not controlled by the host controller. In that case, the controller must be fully reset on resume.
--- drivers/mmc/host/sdhci.c | 13 +++++++++++-- include/linux/mmc/sdhci.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +11 -2
@@ -2426,8 +2426,17 @@ int sdhci_resume_host(struct sdhci_host *host)if (ret)return ret; -sdhci_init (host, (host->mmc->pm_flags &MMC_PM_KEEP_POWER )); -mmiowb (); +if ((host->mmc->pm_flags &MMC_PM_KEEP_POWER ) && + (host->quirks2 &SDHCI_QUIRK2_HOST_OFF_CARD_ON )) { +/* Card keeps power but host controller does not */ +sdhci_init (host,0 ); + host->pwr =0 ; + host->clock =0 ; +sdhci_do_set_ios (host, &host->mmc->ios); + }else { +sdhci_init (host, (host->mmc->pm_flags &MMC_PM_KEEP_POWER )); +mmiowb (); + } ret =mmc_resume_host (host->mmc);sdhci_enable_card_detection (host);
include/linux/mmc/sdhci.h +2 -0
@@ -90,6 +90,8 @@ struct sdhci_host {unsigned int quirks2;/* More deviations from spec. */ +#define SDHCI_QUIRK2_HOST_OFF_CARD_ON (1<<0) +int irq;/* Device IRQ */ void __iomem *ioaddr;/* Mapped address */
Signature · 1 line
1.7.6.4
Adrian Hunter
maintainerPATCH 4/4 mmc: sdhci-pci: add SDHCI_QUIRK2_HOST_OFF_CARD_ON for Medfield SDIO
In reply to Adrian HunterSDIO is powered separated from the host controller, so the card can remain on while the host controller is powered off during suspend.
--- drivers/mmc/host/sdhci-pci.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-pci.c +5 -0
@@ -47,6 +47,7 @@ struct sdhci_pci_slot;struct sdhci_pci_fixes {unsigned int quirks; +unsigned int quirks2;bool allow_runtime_pm;int (*probe) (struct sdhci_pci_chip *);
@@ -73,6 +74,7 @@ struct sdhci_pci_chip {struct pci_dev *pdev;unsigned int quirks; +unsigned int quirks2;bool allow_runtime_pm;const struct sdhci_pci_fixes *fixes;
@@ -272,6 +274,7 @@ static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = {static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = { .quirks =SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC , + .quirks2 =SDHCI_QUIRK2_HOST_OFF_CARD_ON , .allow_runtime_pm = true, .probe_slot = mfd_sdio_probe_slot, };
@@ -1207,6 +1210,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( host->hw_name ="PCI" ; host->ops = &sdhci_pci_ops; host->quirks = chip->quirks; + host->quirks2 = chip->quirks2; host->irq = pdev->irq;
@@ -1366,6 +1370,7 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev, chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data;if (chip->fixes) { chip->quirks = chip->fixes->quirks; + chip->quirks2 = chip->fixes->quirks2; chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; } chip->num_slots = slots;
Signature · 1 line
1.7.6.4
Adrian Hunter
maintainerQuoted 14 lines · Adrian Hunter
Hi
Here are patches for Medfield to allow the use of high-capacity erase size and to allow the SDIO host controller to be off when the card is kept on during suspend - replacing the earlier patch "mmc: sdhci: always reset all during resume"
Adrian Hunter (4):
mmc: core: add high-capacity erase size capability flag
mmc: sdhci-pci: select HC erase size for Medfield eMMC
mmc: sdhci: add quirk for keeping card power during suspend
mmc: sdhci-pci: addSDHCI_QUIRK2_HOST_OFF_CARD_ONfor Medfield SDIO
Quoted 6 lines
drivers/mmc/core/mmc.c | 3 ++- drivers/mmc/host/sdhci-pci.c | 8 +++++++- drivers/mmc/host/sdhci.c | 13 +++++++++++-- include/linux/mmc/host.h | 1 + include/linux/mmc/sdhci.h | 2 ++ 5 files changed, 23 insertions(+), 4 deletions(-)
Chris can you take these?
MMC_CAP2_HC_ERASE_SZ needs to move to bit9 but otherwise they apply.
Hi Adrian,
Quoted 22 lines · Adrian Hunter
Quoted 14 lines · Adrian Hunter
Hi
Here are patches for Medfield to allow the use of high-capacity erase size and to allow the SDIO host controller to be off when the card is kept on during suspend - replacing the earlier patch "mmc: sdhci: always reset all during resume"
Adrian Hunter (4):
mmc: core: add high-capacity erase size capability flag
mmc: sdhci-pci: select HC erase size for Medfield eMMC
mmc: sdhci: add quirk for keeping card power during suspend
mmc: sdhci-pci: addSDHCI_QUIRK2_HOST_OFF_CARD_ONfor Medfield SDIOQuoted 6 lines
drivers/mmc/core/mmc.c | 3 ++- drivers/mmc/host/sdhci-pci.c | 8 +++++++- drivers/mmc/host/sdhci.c | 13 +++++++++++-- include/linux/mmc/host.h | 1 + include/linux/mmc/sdhci.h | 2 ++ 5 files changed, 23 insertions(+), 4 deletions(-)
Quoted 3 lines
Chris can you take these?
MMC_CAP2_HC_ERASE_SZneeds to move to bit9 but otherwise they apply.
Thanks for the reminder, moved MMC_CAP2_HC_ERASE_SZ to bit9 and pushed to mmc-next for 3.4.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child