Skip to content

Commit

Permalink
mmc: use downstream DT property to modify CQE and/or SD CQ behaviour
Browse files Browse the repository at this point in the history
Implement a tristate-style option for "supports-cqe". If the property is
absent or zero, disable CQ completely. For 1, enable CQ unconditionally
for eMMC cards, and known-good SD cards. For 2, enable for eMMC cards,
and all SD cards that are not known-bad.

The sdhci-brcmstb driver needs to know about the tristate as its probe
sequence would otherwise override a disable in mmc_of_parse().

Signed-off-by: Jonathan Bell <[email protected]>
  • Loading branch information
P33M authored and pelwell committed Jan 10, 2025
1 parent 15fd6ee commit e30a581
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
11 changes: 10 additions & 1 deletion drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ EXPORT_SYMBOL(mmc_of_parse_clk_phase);
int mmc_of_parse(struct mmc_host *host)
{
struct device *dev = host->parent;
u32 bus_width, drv_type, cd_debounce_delay_ms;
u32 bus_width, drv_type, cd_debounce_delay_ms, cq_allow;
int ret;

if (!dev || !dev_fwnode(dev))
Expand Down Expand Up @@ -407,6 +407,15 @@ int mmc_of_parse(struct mmc_host *host)
host->caps2 &= ~(MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V |
MMC_CAP2_HS400_ES);

cq_allow = 0;
/*
* Downstream property - if a u32 and 2 instead of a bool,
* trust most A2 SD cards claiming CQ support.
*/
device_property_read_u32(dev, "supports-cqe", &cq_allow);
if (cq_allow == 2)
host->caps2 |= MMC_CAP2_SD_CQE_PERMISSIVE;

/* Must be after "non-removable" check */
if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) {
if (host->caps & MMC_CAP_NONREMOVABLE)
Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/core/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,8 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
goto free_card;
}

/* Disallow command queueing on unvetted cards */
if (!mmc_card_working_sd_cq(card))
/* Disallow command queueing on unvetted cards unless overridden */
if (!(host->caps2 & MMC_CAP2_SD_CQE_PERMISSIVE) && !mmc_card_working_sd_cq(card))
card->ext_csd.cmdq_support = false;

/* Enable command queueing if supported */
Expand Down
6 changes: 4 additions & 2 deletions drivers/mmc/host/sdhci-brcmstb.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
struct sdhci_pltfm_host *pltfm_host;
const struct of_device_id *match;
struct sdhci_brcmstb_priv *priv;
u32 actual_clock_mhz;
u32 actual_clock_mhz, cqe;
struct sdhci_host *host;
struct resource *iomem;
bool no_pinctrl = false;
Expand Down Expand Up @@ -600,7 +600,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
pltfm_host->clk = clk;

priv = sdhci_pltfm_priv(pltfm_host);
if (device_property_read_bool(&pdev->dev, "supports-cqe")) {
cqe = 0;
device_property_read_u32(&pdev->dev, "supports-cqe", &cqe);
if (cqe > 0) {
priv->flags |= BRCMSTB_PRIV_FLAGS_HAS_CQE;
match_priv->ops->irq = sdhci_brcmstb_cqhci_irq;
}
Expand Down
1 change: 1 addition & 0 deletions include/linux/mmc/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ struct mmc_host {
#define MMC_CAP2_CRYPTO 0
#endif
#define MMC_CAP2_ALT_GPT_TEGRA (1 << 28) /* Host with eMMC that has GPT entry at a non-standard location */
#define MMC_CAP2_SD_CQE_PERMISSIVE (1 << 31) /* Ignore allow-list for CQ capable SD card detection */

int fixed_drv_type; /* fixed driver type for non-removable media */

Expand Down

0 comments on commit e30a581

Please sign in to comment.