From patchwork Wed Oct 20 10:29:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 516000 Delivered-To: patches@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp1624154imp; Wed, 20 Oct 2021 03:29:27 -0700 (PDT) X-Received: by 2002:a05:6512:3b8b:: with SMTP id g11mr11393425lfv.216.1634725766963; Wed, 20 Oct 2021 03:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634725766; cv=none; d=google.com; s=arc-20160816; b=BIJIkeFrdhpPsoAGmGqfYlexYRvyIdkMTOBS0YUZdoaR0Mt5Oem1GURwVei7pp+lCD /HNMxhGgIBwtynK94VzTuBe/srCoHLcZTLZvsrIesP3n0XJKI/7qTQSIkYrU4iAKQgLe x0XFJyPP1IBycL4x0cy55HjAExh0swW+5kuVVIn/JHT/vrGY13IIUcUBLZx5iMVibmnr AnSkS/UP4p+WSWdl39aN+0k4ZsA50SczfQQGLpAYZGQJVlS/Dil7uCIj5x6r58gyu0Kx 8CNBOdh9rCuKZBgEeezjMeEwDFhDTz39jNjKgvRWV1Wj4HH0BxFdLd3gzsVWQodo/n0/ mTew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=/FuRIXAF4mrPwG+ZHHhikoeSd7OTNEOOMYIygH7Yo04=; b=JDVG/Qx9MPC8w5AWZwWC2DspkOHA/1nvN2JiFvBg+7Rrtm1QWRJVeikN5Ce+IMCmTu YJdD9F4aaetUndyHZpsIVHxK780lMM8ingKBMHIXcT9LCahSJ+CiB0p31qxuiO2z3zb/ QSnUTW7DdHxPwLnAzZ1qoSoQdPaAQ6yCKcCEdnzPnPRMDKFunTViHC9YdnSXwKlvR40n 1TAUjLEM/Y0yxhrXFrzrC9svZNgCHdn14S9v7viCi9EtwRL23Cf89BQm5HigJD7z9Kk8 1sgEBj+rXuMgZrlXkt4IS7MjimvuIR+HnBnuMTiy8JGxetjIiBimwDlaPDIzosKZqAgA R6Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iPLuR+8g; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id l24sor854272lji.57.2021.10.20.03.29.26 for (Google Transport Security); Wed, 20 Oct 2021 03:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iPLuR+8g; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/FuRIXAF4mrPwG+ZHHhikoeSd7OTNEOOMYIygH7Yo04=; b=iPLuR+8gwSNZd6AuFhQ1Uie5MEVNjdrq4sMve9XqdwN6rrc/pSOmExwAo/TFCY0w+X nwKu83h44fYGoEW4W708mb6K8sDgDcs2jp60Hl+6P4dWFZphofrvsidy/OIgT/bwnTiM Garwk0S3Ti8A+clLSFPZO2ODpWpU+SICp+VpnAyux1+OrqW95+kyyR+RujuWRUAjifzZ 9wx1Y+j9WQFocuG89haQTW+pfd7gJ4WRtLglbGP7neGa6P+bHKso4GAHp3ZGIuhrY58i ha0UMO/HiKypOxJRUmXrJoBGlNWKpJzQltKUkQmaRNfkGeYrLe/1nNoReSzvXbPBmt5A XsQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/FuRIXAF4mrPwG+ZHHhikoeSd7OTNEOOMYIygH7Yo04=; b=C6hqmWV4vNIoShw5eCgfQvmxuKW6QPO7zaKKFQJDT5kLlbYWGQPHgetCKlrWtoLIer 4OomgSg9OhY42kBb+JgJLF3ZX8gpw4Bqm31t5WHKtKSKM4HXqHjWMjDmvbx8qH7ucqDG +kEg4+9oufPwRkU6HMd+/WNdpYNEpOQKRUrj0sz8fTeMvZKzHLL6Zylg6ALoRQAMLY5E AVgCsKV3UaOXDHWX0TyDpa1JgR7S5hSjhx/pxyKtjX0n80p1mEGlzYjumbXMecFUaUUV PS5WyeMICl6/lehzlUlSghSkQwMHTPhv5qRR0enFmkW54caL8+dyqam+qQP4xgNj+lD4 UB0g== X-Gm-Message-State: AOAM530rTmq8aaF03gBpvLe9fSGikUsLgzgFcFhR5nnT6kuTRvJgKycc cvBjm96rY5pFMYleh54gF2nNJ2bG X-Google-Smtp-Source: ABdhPJw2uTcCvKkapBHvjuVhv6Fi4/aV/cEhgvolT8M+MqRJuYfQSFIYnfINSGnjsb4D0Zl4R3lK6w== X-Received: by 2002:a2e:a40f:: with SMTP id p15mr12964426ljn.497.1634725766611; Wed, 20 Oct 2021 03:29:26 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id x10sm160343lff.44.2021.10.20.03.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 03:29:25 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Douglas Anderson , Matthias Kaehlcke , Shawn Lin Subject: [PATCH] mmc: dw_mmc: Drop use of ->init_card() callback Date: Wed, 20 Oct 2021 12:29:07 +0200 Message-Id: <20211020102907.70195-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 For dw_mmc, the ->init_card() callback is being used to turn on/off automatic internal clock gating for powersave, which is needed to properly support SDIO irqs on DAT1. However, using the ->init_card() comes with a drawback in this case, as it means that the powersave feature becomes disabled, no matter whether the SDIO irqs becomes turned on or not. To improve the behaviour, let's change into using the ->enable_sdio_irq() callback instead. This works fine, because dw_mmc uses sdio_signal_irq() to signal the irqs, thus the ->enable_sdio_irq() is never executed from within atomic context. Signed-off-by: Ulf Hansson --- drivers/mmc/host/dw_mmc.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) -- 2.25.1 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 1e8f1bb3cad7..d977f34f6b55 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1611,37 +1611,32 @@ static void dw_mci_hw_reset(struct mmc_host *mmc) usleep_range(200, 300); } -static void dw_mci_init_card(struct mmc_host *mmc, struct mmc_card *card) +static void dw_mci_prepare_sdio_irq(struct dw_mci_slot *slot, bool prepare) { - struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci *host = slot->host; + const u32 clken_low_pwr = SDMMC_CLKEN_LOW_PWR << slot->id; + u32 clk_en_a_old; + u32 clk_en_a; /* * Low power mode will stop the card clock when idle. According to the * description of the CLKENA register we should disable low power mode * for SDIO cards if we need SDIO interrupts to work. */ - if (mmc->caps & MMC_CAP_SDIO_IRQ) { - const u32 clken_low_pwr = SDMMC_CLKEN_LOW_PWR << slot->id; - u32 clk_en_a_old; - u32 clk_en_a; - clk_en_a_old = mci_readl(host, CLKENA); - - if (card->type == MMC_TYPE_SDIO || - card->type == MMC_TYPE_SD_COMBO) { - set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); - clk_en_a = clk_en_a_old & ~clken_low_pwr; - } else { - clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); - clk_en_a = clk_en_a_old | clken_low_pwr; - } + clk_en_a_old = mci_readl(host, CLKENA); + if (prepare) { + set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); + clk_en_a = clk_en_a_old & ~clken_low_pwr; + } else { + clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); + clk_en_a = clk_en_a_old | clken_low_pwr; + } - if (clk_en_a != clk_en_a_old) { - mci_writel(host, CLKENA, clk_en_a); - mci_send_cmd(slot, SDMMC_CMD_UPD_CLK | - SDMMC_CMD_PRV_DAT_WAIT, 0); - } + if (clk_en_a != clk_en_a_old) { + mci_writel(host, CLKENA, clk_en_a); + mci_send_cmd(slot, SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, + 0); } } @@ -1669,6 +1664,7 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci *host = slot->host; + dw_mci_prepare_sdio_irq(slot, enb); __dw_mci_enable_sdio_irq(slot, enb); /* Avoid runtime suspending the device when SDIO IRQ is enabled */ @@ -1790,7 +1786,6 @@ static const struct mmc_host_ops dw_mci_ops = { .execute_tuning = dw_mci_execute_tuning, .card_busy = dw_mci_card_busy, .start_signal_voltage_switch = dw_mci_switch_voltage, - .init_card = dw_mci_init_card, .prepare_hs400_tuning = dw_mci_prepare_hs400_tuning, };