From patchwork Wed Apr 25 12:09:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 134254 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp779024lji; Wed, 25 Apr 2018 05:10:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+cXh97B1/YQ0l0RXlTHji7P0okcTr7r3IdggMbEewgPfqEI6DjdOKsqhXVIUFSSabBkuTB X-Received: by 2002:a17:902:a603:: with SMTP id u3-v6mr29222495plq.214.1524658220464; Wed, 25 Apr 2018 05:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524658220; cv=none; d=google.com; s=arc-20160816; b=sQ50H3Ot/inFh/hbpb6PsGDPVfQOt4jVnoHvIkNDwGB74pUhzmIzN1YWtmii27gfA9 8pF/X5JwfjlZ5uFEGDmeBA75hdMng5wHCq7dc1zbCzKFhM3cc+FHA3mouF77RmUuu3ln uVCzOfHqss06uVe+Y/KyGvG+lEULPVZlSU3huU9pb09wEgaTiMivLz2/kaR5lnBY7n22 PW16KxZM+6PnpwWYpAYMNOxS7eFaKT5lCS55e4vt4lmXZSyCIws4hPpbF7h1sUM8NcxR +quh1Ni5+0dwuf+JrcUvPnPBChbkOOw94oho0ZB2O8tCVwCezBu/AlUwut7ru0XPRL8k oSfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=6OvxDYSr0FraS4HLEoiFtRxfScJF3TDfg3XmbA8nLGQ=; b=orBBuUGnocZry4DujvQ9z/Z6n4KjeRxXmYUffQmUCIXIfd8UQRhndBDuVCwLvpyX61 VFn3MfKhfNuYn5J0zAr+9ObtNaybwXF4h/1bGlX74vBpjqb3kOuXN5KYvNWnsoCN2zA7 l9jF4yuzSVYfNESFQN8uAfFtmCbMMWdX7q8L/Rn0SVWFVt9aPFk93roRoKZfhckLBOcu XGAyVm/7QoZsGHAa6++V1fGASEUSX2L5o26DRJm9u4JsV21oEWHzbXAbnLkVRdDx+noy 2r3qVfa6PK4gKt7t+hVrBu5PeLST+ANHmq7L2FCch1KnP0MZ+gSpWZDo+DJg6psX0sSr JM9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=DoK4fncv; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a123si13650325pgc.43.2018.04.25.05.10.20; Wed, 25 Apr 2018 05:10:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=DoK4fncv; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753157AbeDYMKS (ORCPT + 5 others); Wed, 25 Apr 2018 08:10:18 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:63442 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752785AbeDYMKM (ORCPT ); Wed, 25 Apr 2018 08:10:12 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3PCA6Rn018891; Wed, 25 Apr 2018 07:10:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1524658206; bh=niQzSScxUplumje1ksG05RgPXuCxbuOYOyYTH6hi0hk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DoK4fncv92NS3jkLy2EnWXZLZkDDLxBLxIKI5p1rRzthRKLG7GucbNjJQiRwH9rFW znaipX4arMEfcHYz3j84SdL1MAarodip4d2YvAbK+itpbhtLuW5Jf+idOMNcKD+GBm fDSpnByLP/Qp0Uy5RcShmTy1XDYAYFtzvdqCngpQ= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3PCA6qv017232; Wed, 25 Apr 2018 07:10:06 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 25 Apr 2018 07:10:06 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 25 Apr 2018 07:10:06 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3PC9hhT009970; Wed, 25 Apr 2018 07:10:03 -0500 From: Kishon Vijay Abraham I To: Ulf Hansson , Adrian Hunter CC: , Rob Herring , Mark Rutland , , , , , Tony Lindgren Subject: [PATCH v4 06/12] mmc: sdhci: Add quirk to disable HW timeout Date: Wed, 25 Apr 2018 17:39:31 +0530 Message-ID: <20180425120937.29867-7-kishon@ti.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425120937.29867-1-kishon@ti.com> References: <20180425120937.29867-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Adrian Hunter Add quirk to disable HW timeout if the requested timeout is more than the maximum obtainable timeout. Also, if the quirk is set and ->get_max_timeout_count() is not implemented, max_busy_timeout is set to zero. Based-on-patch-by: Kishon Vijay Abraham I Signed-off-by: Adrian Hunter Signed-off-by: Kishon Vijay Abraham I --- drivers/mmc/host/sdhci.c | 38 ++++++++++++++++++++++++++++++++++---- drivers/mmc/host/sdhci.h | 5 +++++ 2 files changed, 39 insertions(+), 4 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index b5f047b5f3ae..b91163de4da4 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -709,12 +709,15 @@ static u32 sdhci_sdma_address(struct sdhci_host *host) return sg_dma_address(host->data->sg); } -static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) +static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd, + bool *too_big) { u8 count; struct mmc_data *data = cmd->data; unsigned target_timeout, current_timeout; + *too_big = true; + /* * If the host controller provides us with an incorrect timeout * value, just skip the check and use 0xE. The hardware may take @@ -768,9 +771,12 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) } if (count >= 0xF) { - DBG("Too large timeout 0x%x requested for CMD%d!\n", - count, cmd->opcode); + if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT)) + DBG("Too large timeout 0x%x requested for CMD%d!\n", + count, cmd->opcode); count = 0xE; + } else { + *too_big = false; } return count; @@ -790,6 +796,16 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host) sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); } +static void sdhci_set_data_timeout_irq(struct sdhci_host *host, bool enable) +{ + if (enable) + host->ier |= SDHCI_INT_DATA_TIMEOUT; + else + host->ier &= ~SDHCI_INT_DATA_TIMEOUT; + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); +} + static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) { u8 count; @@ -797,7 +813,17 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) if (host->ops->set_timeout) { host->ops->set_timeout(host, cmd); } else { - count = sdhci_calc_timeout(host, cmd); + bool too_big = false; + + count = sdhci_calc_timeout(host, cmd, &too_big); + + if (too_big && + host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) { + sdhci_set_data_timeout_irq(host, false); + } else if (!(host->ier & SDHCI_INT_DATA_TIMEOUT)) { + sdhci_set_data_timeout_irq(host, true); + } + sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); } } @@ -3616,6 +3642,10 @@ int sdhci_setup_host(struct sdhci_host *host) mmc->max_busy_timeout /= host->timeout_clk; } + if (host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT && + !host->ops->get_max_timeout_count) + mmc->max_busy_timeout = 0; + mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23; mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index c95b0a4a7594..f6555c0f4ad3 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -437,6 +437,11 @@ struct sdhci_host { #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15) /* Controller has CRC in 136 bit Command Response */ #define SDHCI_QUIRK2_RSP_136_HAS_CRC (1<<16) +/* + * Disable HW timeout if the requested timeout is more than the maximum + * obtainable timeout. + */ +#define SDHCI_QUIRK2_DISABLE_HW_TIMEOUT (1<<17) int irq; /* Device IRQ */ void __iomem *ioaddr; /* Mapped address */