From patchwork Thu Dec 6 15:18:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10716147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF55C14E2 for ; Thu, 6 Dec 2018 15:18:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B03629AE5 for ; Thu, 6 Dec 2018 15:18:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D67C2EC6E; Thu, 6 Dec 2018 15:18:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1180F29AE5 for ; Thu, 6 Dec 2018 15:18:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=igdGioWgLuBc3nhFc/2B6fiO8Zn9dAFwGy/jEzgOt5s=; b=fdlpkaUC9oDAdY Uf8BWQowsJ8DVSYCqKnuSd20mNODwwWo8d7sRT+ebdLPKV0flr45aCk/UvpHBYmpqEjxlsXE54m2y JIfaVvB9PEcImLOlNWsPcztDhogDBteYMUdriaOtoeOsSFvWgCneYPjb4He363qwLxneQYGF8yOVs HrVMZpRfZiCP3jTsL4FA/9+pl+y+PvlprTebdgMFadg5Eds2pLKCFFk1q1FkldSTq4Cg2ZIGSA+je UjgjqIKKBKO3J0jHsidFP2ZEEIBxKnv755ola7Rml+vOJUWC1FweQRWe4PsWfpcO48xeuZZO7jGi8 iKaulMrplnSOn8QNlmfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQR-0008Ce-Fw; Thu, 06 Dec 2018 15:18:51 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQO-00089i-3h for linux-amlogic@lists.infradead.org; Thu, 06 Dec 2018 15:18:50 +0000 Received: by mail-wr1-x443.google.com with SMTP id p4so852981wrt.7 for ; Thu, 06 Dec 2018 07:18:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IQ1pNjxAYQJEy/wzhy8LaXlzyI+EffZDKMSvsOZcQ9o=; b=acMyHwrt8WgUGbImx9XBPcsSw2WvrcbkjNowHm4RCMrQJ7XXJZ9LcOpXwNKXzOoXB+ QsQd2L97Ag48Goc5hiLqAq4RoklHafsgH26vd19mbEdTDx/sD1J5yb2UXZzhjl79pNQU Vawqbb1mvm6KUoh+nFgzlbgppYUIW7Bo0pOqNtyZSBBI1p9VmAzEkgOn6f9NdYDO3DWb VR5PqVvPcgZUVbTT1nVfSBolvwRzQm2UYbpfmCVtog01V4Hxc2WJL5ROpb3oKmM5ju1u 8iZse5p76cdHWXAMkM0VV0VPqL1UYWk819PXPt7XxQZ31VTHoHLM/UF05srG9VNBmuLC dE1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IQ1pNjxAYQJEy/wzhy8LaXlzyI+EffZDKMSvsOZcQ9o=; b=JtTmpSjLuLRRFjN7LAT7+6efpQQGSmAVvf/HLEyhnOiQBNwr8W35RkCw7cdekHxuhV 4iLsMxtJ3+4S4tUNJT/perYMtuM+3PTFiVfbJedymL51TEANxanO4wc2S6KUVB3uSmmT eoSRJzkDcuw2B+cnmIJ36vaMUbhjMWnt4+OjnrN9lYcaHcgS6hsux8u8NaYQkFWbDm4R 8pmkivs5GLCoP30LqIWzobjih3suxasY7KocW77W0QodpUrl5emcaCEYMKdpdPf1271B WRMjsiEOxGGG8l6qFX0xo10CulINuggz05Mu5kgK2jI1FIFGyGwMywt3tj+7kRchOhrz 7y2g== X-Gm-Message-State: AA+aEWZc9ZEMMNiHG0GHGojgVfbQksEg4jkv4a5bvlsZmtqTC4lTcunm p6V1y1GOn86VdWs3opyW0m3d3A== X-Google-Smtp-Source: AFSGD/U8nu1DsCPYsh2NpH8OPun8NLHb8LoJrqrEDBbNcqDltn6ibXdObfZSfShbSLcVoun+L/F78w== X-Received: by 2002:adf:ce86:: with SMTP id r6mr27113095wrn.257.1544109517755; Thu, 06 Dec 2018 07:18:37 -0800 (PST) Received: from boomer.local ([2a01:e34:eeb6:4690:106b:bae3:31ed:7561]) by smtp.googlemail.com with ESMTPSA id j33sm939652wre.91.2018.12.06.07.18.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 07:18:37 -0800 (PST) From: Jerome Brunet To: Ulf Hansson , Carlo Caione , Kevin Hilman Subject: [PATCH 1/4] mmc: meson-gx: make sure the descriptor is stopped on errors Date: Thu, 6 Dec 2018 16:18:25 +0100 Message-Id: <20181206151828.24417-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206151828.24417-1-jbrunet@baylibre.com> References: <20181206151828.24417-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_071848_158369_0FF821C0 X-CRM114-Status: GOOD ( 17.76 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On errors, if we don't stop the descriptor chain, it may continue to run and raise IRQ after we have called mmc_request_done(). This is bad because we won't be able to get cmd anymore and properly deal with the IRQ. This patch makes sure the descriptor chain is stopped before calling mmc_request_done() Fixes: 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode") Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 73 ++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index c201c378537e..fcb5d693c897 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -90,9 +91,11 @@ #define CFG_CLK_ALWAYS_ON BIT(18) #define CFG_CHK_DS BIT(20) #define CFG_AUTO_CLK BIT(23) +#define CFG_ERR_ABORT BIT(27) #define SD_EMMC_STATUS 0x48 #define STATUS_BUSY BIT(31) +#define STATUS_DESC_BUSY BIT(30) #define STATUS_DATI GENMASK(23, 16) #define SD_EMMC_IRQ_EN 0x4c @@ -928,6 +931,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) cmd_cfg |= FIELD_PREP(CMD_CFG_CMD_INDEX_MASK, cmd->opcode); cmd_cfg |= CMD_CFG_OWNER; /* owned by CPU */ + cmd_cfg |= CMD_CFG_ERROR; /* stop in case of error */ meson_mmc_set_response_bits(cmd, &cmd_cfg); @@ -1022,6 +1026,17 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) u32 irq_en, status, raw_status; irqreturn_t ret = IRQ_NONE; + irq_en = readl(host->regs + SD_EMMC_IRQ_EN); + raw_status = readl(host->regs + SD_EMMC_STATUS); + status = raw_status & irq_en; + + if (!status) { + dev_dbg(host->dev, + "Unexpected IRQ! irq_en 0x%08x - status 0x%08x\n", + irq_en, raw_status); + return IRQ_NONE; + } + if (WARN_ON(!host) || WARN_ON(!host->cmd)) return IRQ_NONE; @@ -1029,22 +1044,18 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) cmd = host->cmd; data = cmd->data; - irq_en = readl(host->regs + SD_EMMC_IRQ_EN); - raw_status = readl(host->regs + SD_EMMC_STATUS); - status = raw_status & irq_en; - cmd->error = 0; if (status & IRQ_CRC_ERR) { dev_dbg(host->dev, "CRC Error - status 0x%08x\n", status); cmd->error = -EILSEQ; - ret = IRQ_HANDLED; + ret = IRQ_WAKE_THREAD; goto out; } if (status & IRQ_TIMEOUTS) { dev_dbg(host->dev, "Timeout - status 0x%08x\n", status); cmd->error = -ETIMEDOUT; - ret = IRQ_HANDLED; + ret = IRQ_WAKE_THREAD; goto out; } @@ -1069,17 +1080,49 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) /* ack all enabled interrupts */ writel(irq_en, host->regs + SD_EMMC_STATUS); + if (cmd->error) { + /* Stop desc in case of errors */ + u32 start = readl(host->regs + SD_EMMC_START); + + start &= ~START_DESC_BUSY; + writel(start, host->regs + SD_EMMC_START); + } + if (ret == IRQ_HANDLED) meson_mmc_request_done(host->mmc, cmd->mrq); - else if (ret == IRQ_NONE) - dev_warn(host->dev, - "Unexpected IRQ! status=0x%08x, irq_en=0x%08x\n", - raw_status, irq_en); spin_unlock(&host->lock); return ret; } +static int meson_mmc_wait_desc_stop(struct meson_host *host) +{ + int loop; + u32 status; + + /* + * It may sometimes take a while for it to actually halt. Here, we + * are giving it 5ms to comply + * + * If we don't confirm the descriptor is stopped, it might raise new + * IRQs after we have called mmc_request_done() which is bad. + */ + for (loop = 50; loop; loop--) { + status = readl(host->regs + SD_EMMC_STATUS); + if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) + udelay(100); + else + break; + } + + if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) { + dev_err(host->dev, "Timed out waiting for host to stop\n"); + return -ETIMEDOUT; + } + + return 0; +} + static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) { struct meson_host *host = dev_id; @@ -1090,6 +1133,13 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) if (WARN_ON(!cmd)) return IRQ_NONE; + if (cmd->error) { + meson_mmc_wait_desc_stop(host); + meson_mmc_request_done(host->mmc, cmd->mrq); + + return IRQ_HANDLED; + } + data = cmd->data; if (meson_mmc_bounce_buf_read(data)) { xfer_bytes = data->blksz * data->blocks; @@ -1130,6 +1180,9 @@ static void meson_mmc_cfg_init(struct meson_host *host) cfg |= FIELD_PREP(CFG_RC_CC_MASK, ilog2(SD_EMMC_CFG_CMD_GAP)); cfg |= FIELD_PREP(CFG_BLK_LEN_MASK, ilog2(SD_EMMC_CFG_BLK_SIZE)); + /* abort chain on R/W errors */ + cfg |= CFG_ERR_ABORT; + writel(cfg, host->regs + SD_EMMC_CFG); } From patchwork Thu Dec 6 15:18:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10716153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F415814E2 for ; Thu, 6 Dec 2018 15:19:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E221228A25 for ; Thu, 6 Dec 2018 15:19:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D62B82E09E; Thu, 6 Dec 2018 15:19:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86C3828A25 for ; Thu, 6 Dec 2018 15:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BvFUV4JUybr8vE1dOuX/tpcJfF6dcuKTxCxL/71R+bk=; b=iSwS3KjdP5AvRA 2AhBJjs7tS4qLiwre99sisWk1q5jwNyFIsIfPfjONkk0eKNR6hjhLRv+aV0s5I3i2GYY3onYQtmqN 88zZ3sWc9n5NjVkWyY41TQ7jDKNYLXlN2bJ2p7BdO+d1yZSq8Qkyx/jcpMYXJOOwxrZ9BRFX5zoiI nOqYy9y1xd3hcgaTjXydP6csiyx738tH9meMjIz1y7bqmanxFa7F8obpbwynRr2NUQwAXXgyRp4bw nqz+U9HuJvYebU8PKPO1sQOrrSDeU0BXXNfI2clVOGdd0N+jVwMOv6bbG1E8z0UgVu0fgGGr9yDCC MsCyBl//wDQBxYseYnDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQZ-0008Kn-P8; Thu, 06 Dec 2018 15:18:59 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQS-00089k-94 for linux-amlogic@lists.infradead.org; Thu, 06 Dec 2018 15:18:58 +0000 Received: by mail-wm1-x342.google.com with SMTP id a18so1462395wmj.1 for ; Thu, 06 Dec 2018 07:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y7CGHPuU0cKd8uxanXCkssfy7HoOVVH2fzqpoBO3MJk=; b=c+bM7IaWZi1H/3FYMQILbAyq3SkhW7Uih01O/P0gAfzhOuiZ5bnjA7L7I8NlwiHI/h H3OzC5LtUaJ3Tt+AqTqgP6zvsv3H3STi6sCHOoc3iiUkw9VJrjD4nw/ljk7rlFdYfZPZ n9lPPlK5rN0Rt2KtNVt7DMayET1i97tQKB+A5OnowPY5mN2MIKF5C1RarI4cDEb+fwkb IkTZ+bGtP7E5G0DsA5fVu/lPbzIQ+6aL4I1rL7Nn9MWo8aAK30cScv/o+rlOFACB4wVa 8Gbqh2mm58L1zsQhs1IgVCxGbY17DH2CUdB7UUG5H4rwVYbzRKmnjuPV8alx7YokJN9m wi+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y7CGHPuU0cKd8uxanXCkssfy7HoOVVH2fzqpoBO3MJk=; b=eJgqyoloLdn7rdiv3g//Y9/rWphsvZpvJBw9KBJdGFe4tZ9XdxmOu5S6G82JQVVa0E nT2s0/Gl4+T5ZT0GKIayRaQ84Gz4nJLEhVYNYTX/3c9li4RiAtoFiaZaC8PxblBH/YjM CnICkjw7arfbPcO6o19zmpWHDdNdZQP68w3FIuB6wQdIyTvT3gnSW6HFTOTa1xKEXicw Qvqt1TuCQQoPfSM4uCVI1V6QqU72K1zdPlKLPDi1i1sRbdiOmli9mYM6PjNGFtIdceZh Ate8MGfc0+/9GJOZJXhJYqwiPUu77NZjJbYo4HxdkEkWPe7om7L3ZAzqzllfk5e0Ohwc zrJQ== X-Gm-Message-State: AA+aEWYCUml4BbEl+5Ql3/dcIGtVTHBAENd0wA7JxO6a9vS5idj5UpF/ ILhpZ+b42I/DuTCeE+Y6O2/6tg== X-Google-Smtp-Source: AFSGD/Xv9y5Gp69PrLbFCQosYzPu0t940Sru5qC/QjA70Z1iyheNfOgkmA5JlbjaAS+UP/JrjTlFjw== X-Received: by 2002:a7b:c1d7:: with SMTP id a23mr19076799wmj.48.1544109519103; Thu, 06 Dec 2018 07:18:39 -0800 (PST) Received: from boomer.local ([2a01:e34:eeb6:4690:106b:bae3:31ed:7561]) by smtp.googlemail.com with ESMTPSA id j33sm939652wre.91.2018.12.06.07.18.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 07:18:38 -0800 (PST) From: Jerome Brunet To: Ulf Hansson , Carlo Caione , Kevin Hilman Subject: [PATCH 2/4] mmc: meson-gx: remove useless lock Date: Thu, 6 Dec 2018 16:18:26 +0100 Message-Id: <20181206151828.24417-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206151828.24417-1-jbrunet@baylibre.com> References: <20181206151828.24417-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_071852_574957_0B4AC0C7 X-CRM114-Status: GOOD ( 10.77 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The spinlock is only used within the irq handler so it does not seem very useful. Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index fcb5d693c897..5cc31e434ca1 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -159,7 +158,6 @@ struct meson_host { struct mmc_host *mmc; struct mmc_command *cmd; - spinlock_t lock; void __iomem *regs; struct clk *core_clk; struct clk *mmc_clk; @@ -1040,8 +1038,6 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) if (WARN_ON(!host) || WARN_ON(!host->cmd)) return IRQ_NONE; - spin_lock(&host->lock); - cmd = host->cmd; data = cmd->data; cmd->error = 0; @@ -1091,7 +1087,6 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) if (ret == IRQ_HANDLED) meson_mmc_request_done(host->mmc, cmd->mrq); - spin_unlock(&host->lock); return ret; } @@ -1244,8 +1239,6 @@ static int meson_mmc_probe(struct platform_device *pdev) host->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, host); - spin_lock_init(&host->lock); - /* Get regulators and the supported OCR mask */ host->vqmmc_enabled = false; ret = mmc_regulator_get_supply(mmc); From patchwork Thu Dec 6 15:18:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10716149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 791E217DB for ; Thu, 6 Dec 2018 15:18:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6618B2E09E for ; Thu, 6 Dec 2018 15:18:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5983A2EC78; Thu, 6 Dec 2018 15:18:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1258C2E09E for ; Thu, 6 Dec 2018 15:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nX6SxjfqAnxby9fNI4fqqTJJibjgj+R8n4JPAttWPKg=; b=mrpppXAI7DaypF 7QqqZoGB91qxwJ5aWpJRYMLwvzexf3m2jpyBNQPRszkXZ9BkVcgVNfmoYpe+fSxnvrfPI2sb8lskA K4sxC7Wck6LQzbHB9xNiF4IW5nntqKTjX+X3B/TxOHh9EfSQWP1jBPoLrLZLgBK2RJkEaFYDO/+IE Gpegi8A/wGfkRI5l1WAqSRzxUiH9POwcrW/rmhrcFzxss2itkyot+CAgTLN/w6ONz/J0SqB/JmTRe dv8BX02vbg5DAvagLCRkMPXfvae5mGUG3IhLzmInW8COCdvlag8WZ4zw/CxM/H4hfUCMrSf0U5/2M xR3bHfA/JgLOPN3m63GQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQV-0008Ga-J7; Thu, 06 Dec 2018 15:18:55 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQS-00089o-8o for linux-amlogic@lists.infradead.org; Thu, 06 Dec 2018 15:18:54 +0000 Received: by mail-wm1-x342.google.com with SMTP id f81so1416217wmd.4 for ; Thu, 06 Dec 2018 07:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9D+IWNIkzvM4lr5AWVEe/1dPuYwCLo7SNBs7kvA6F/o=; b=V69wUMG28wtoJtdJvClt8+e4MNUFCgT9w5PW65OzLv56uK4D54BydOiREZ0QqqI6Yj nk587zOLB50DozkpeJgAVwuTXyfanIIiYzRWAk0+RmO0G77yvCTt1HQe0oF4D4U4gIX/ K+tH+Ei85fXP/cer2qzJ+E+nrrcsr/el3V1DRlWJ76S8dnjfpxCG1leb++zeQUGNt0sg 6XjfvIOLWDRXhd5mRCAZ1phYICvS+rKtgvMdf5InGSXVlZ4+w+CAg0FQjtIbn43RSCj6 QUOHKIBu5tWVUobolT9ZHj29k1SSP8jzn7rFngmbZFLolMiGJnzHhBVriKGiMENPrSFY Jnlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9D+IWNIkzvM4lr5AWVEe/1dPuYwCLo7SNBs7kvA6F/o=; b=L4EX6u7wQpFOHGZJTgLXfIoXYot0h5Fds2Wq1jFCMYTFk/tnceTTt3AaU4jR32nvwu 2USJ1f7JkV39BYZO1P5g/YiV3ygrAMaUspWFTPLo4PnW4u1EtjfSCMySmfx8cQJvMTQp tmcg3sT5sM5CqjUlvQ0s+O0Bwkp8qzqfC0+BAIrjllRnPzTpwj04ib4dloaTpyABgVVi SQR94EiMXSuU1yjXxh4Hz6r8dDop517U08dlhTKp9CJlDMjhF/0KzOGdHcvmST0rdRNy 3Ip3issJ0Qqk4qJycbCpfTnlJNgvzz3hsKUwsX8hpKJ33UW3Q88CkTeXByD837myMAY+ 7yHA== X-Gm-Message-State: AA+aEWa8qGDNdtF5Y6hvz2Ir55dA4JDB7SId/+eCf+XIJibURqVSS4qe T24tb7RSr6+UBBLHVUoHbkQ1OQ== X-Google-Smtp-Source: AFSGD/WZLKmAh/mxiuXK9Ct6fORvClnB6EooPxfPYwnm5i979312KWaCMeM6NJhlv80pX5rsGOOQTw== X-Received: by 2002:a1c:9d97:: with SMTP id g145mr20578555wme.152.1544109520556; Thu, 06 Dec 2018 07:18:40 -0800 (PST) Received: from boomer.local ([2a01:e34:eeb6:4690:106b:bae3:31ed:7561]) by smtp.googlemail.com with ESMTPSA id j33sm939652wre.91.2018.12.06.07.18.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 07:18:40 -0800 (PST) From: Jerome Brunet To: Ulf Hansson , Carlo Caione , Kevin Hilman Subject: [RFT PATCH 3/4] mmc: meson-gx: align default phase on soc vendor tree Date: Thu, 6 Dec 2018 16:18:27 +0100 Message-Id: <20181206151828.24417-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206151828.24417-1-jbrunet@baylibre.com> References: <20181206151828.24417-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_071852_661569_BBD25585 X-CRM114-Status: GOOD ( 10.21 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Align the default Core and Tx phase with the SoC vendor tree. Even if the Tx phase is different from what the documentation recommends, it seems to provide better results. Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 5cc31e434ca1..837bed0b8c01 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -634,14 +634,8 @@ static int meson_mmc_clk_init(struct meson_host *host) if (ret) return ret; - /* - * Set phases : These values are mostly the datasheet recommended ones - * except for the Tx phase. Datasheet recommends 180 but some cards - * fail at initialisation with it. 270 works just fine, it fixes these - * initialisation issues and enable eMMC DDR52 mode. - */ clk_set_phase(host->mmc_clk, 180); - clk_set_phase(host->tx_clk, 270); + clk_set_phase(host->tx_clk, 0); clk_set_phase(host->rx_clk, 0); return clk_prepare_enable(host->mmc_clk); From patchwork Thu Dec 6 15:18:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10716151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3E6217DB for ; Thu, 6 Dec 2018 15:18:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C18E929AE5 for ; Thu, 6 Dec 2018 15:18:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5FFB2EC6E; Thu, 6 Dec 2018 15:18:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F6C229AE5 for ; Thu, 6 Dec 2018 15:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gr565SL9KRa0ZYGzJgRkUsEyicm2sYbl1GkwKvbWrgQ=; b=T42WLTaf8KmBEO GBlH22RgFOzYT/X3s3YHSqso8UaXfAi6SgtRHtjz4XjcqKUQzZUfXC0QKnMreofQcsOLxSRGv+O1g ER05Lz6q4XMS4hmH0kiYTFOmJ3dbkHodZfnZaDh54xLYo6P4vyqpvwAlwYUo/MZAMjqUTHlZjyz1d vdJF1eTWLTePMqXOKKccHxGSNpstKDj5aiNdM/b5oO2TZX3//VoBbPYSplLFAgP3uNSF2ldZ6HNO8 rSU3WHV0kbOLmmeJXzxQ2OqfRSTrX+tzK9T/H7dpL37QmP4klhT1bolb9RMMg7kOTN7Ivo2Napan2 vLfBBDvWZPSfOrvVgl8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQX-0008IY-Ky; Thu, 06 Dec 2018 15:18:57 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUvQT-0008AL-J5 for linux-amlogic@lists.infradead.org; Thu, 06 Dec 2018 15:18:56 +0000 Received: by mail-wm1-x343.google.com with SMTP id f81so1416288wmd.4 for ; Thu, 06 Dec 2018 07:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zFuzQAonVH5LBUCWgd9kxnQqOxUMhbJSx8M/Xm/UTNE=; b=NM1hsxe20rGBoKEM0JaW2QIYofsAFl0EeGKtnT2NnuqP0PzMp5TF7JSaBz5V3odkY3 pPUQ76CO16LVvd9exqW4s3b97+TfNK/ryjW27OvZSy9ZFvPVjpKhogSbJFp5ORBm/k9n j2raMNxBEMjSFw0SR4qLVdn1Stzi42R+3CC0WiLZDBJeJJR6zJt5nlFOVbUg/pR482Tx gWHDv+xH78uosEKO/46RRa3OYXlErksskp29L6ga6u2/A5BsTOr/bD5Ed9bY9HDqZLUg /fwB9HtbEAcuFr99Ga2DnOxcLWTVYWACBChB3eNYyZvmpY/xYZmabqLcfLIrfYO9I+1y 0Mhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zFuzQAonVH5LBUCWgd9kxnQqOxUMhbJSx8M/Xm/UTNE=; b=I8KFlERW6tX526BnSUpLIRs9RG6cEq5iJ8dZ/TyUkqDJVorf7VJueMddQ0ha5H6Gxs EMdc1LYZfOBLf/rzQWE1geN5c+cKYsHVwRw9JY+EZPMNDF8UW/Q7adZFGPfTPsozCGot uUVuzTMdbdqTdWEzpgqyeTm0bxT7hOaB6N7aWatxg8MqJfHSjwnFVh0eIlqkcI+bOrAm vInuSiBkn2UDcg/qvEp1HTkVOkEkLbkxbbsG7YgmS80Q6oTSeqyHx35+IED2Ex4Yklh5 87uJR+jpsscn6EgAYvBnCYJnA25RHpnyaCXU4677EuARrlaVU03HoOAXdQ2v7KRItbtS NtIw== X-Gm-Message-State: AA+aEWab3c+cj8BKp56uqZnxn0c/xxGlwwxtsC5PYFNX8yysbVBaQKJ8 SDKZ06YMEA3bbkL8yXPCpvFGyA== X-Google-Smtp-Source: AFSGD/WPuB8R+c4BlfluBlJMpa2T2e3fr20rQlDhnG1K/3zIfrNTc9/AYDvHDgs3Zf4DS2ZlivQvbQ== X-Received: by 2002:a1c:e513:: with SMTP id c19mr21131061wmh.101.1544109522035; Thu, 06 Dec 2018 07:18:42 -0800 (PST) Received: from boomer.local ([2a01:e34:eeb6:4690:106b:bae3:31ed:7561]) by smtp.googlemail.com with ESMTPSA id j33sm939652wre.91.2018.12.06.07.18.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 07:18:41 -0800 (PST) From: Jerome Brunet To: Ulf Hansson , Carlo Caione , Kevin Hilman Subject: [RFT PATCH 4/4] mmc: meson-gx: add signal resampling Date: Thu, 6 Dec 2018 16:18:28 +0100 Message-Id: <20181206151828.24417-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206151828.24417-1-jbrunet@baylibre.com> References: <20181206151828.24417-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_071853_649795_FF34F00A X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With some eMMC devices, there is still issues with the new phase settings. Enabling signal resampling seems to solve the problem for these. Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 837bed0b8c01..c2690c1a50ff 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -66,6 +66,9 @@ #define SD_EMMC_DELAY 0x4 #define SD_EMMC_ADJUST 0x8 +#define ADJUST_ADJ_DELAY_MASK GENMASK(21, 16) +#define ADJUST_DS_EN BIT(15) +#define ADJUST_ADJ_EN BIT(13) #define SD_EMMC_DELAY1 0x4 #define SD_EMMC_DELAY2 0x8 @@ -143,6 +146,7 @@ struct meson_mmc_data { unsigned int tx_delay_mask; unsigned int rx_delay_mask; unsigned int always_on; + unsigned int adjust; }; struct sd_emmc_desc { @@ -1162,7 +1166,7 @@ static int meson_mmc_get_cd(struct mmc_host *mmc) static void meson_mmc_cfg_init(struct meson_host *host) { - u32 cfg = 0; + u32 cfg = 0, adj = 0; cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK, ilog2(SD_EMMC_CFG_RESP_TIMEOUT)); @@ -1173,6 +1177,10 @@ static void meson_mmc_cfg_init(struct meson_host *host) cfg |= CFG_ERR_ABORT; writel(cfg, host->regs + SD_EMMC_CFG); + + /* enable signal resampling w/o delay */ + adj = ADJUST_ADJ_EN; + writel(adj, host->regs + host->data->adjust); } static int meson_mmc_card_busy(struct mmc_host *mmc) @@ -1396,12 +1404,14 @@ static const struct meson_mmc_data meson_gx_data = { .tx_delay_mask = CLK_V2_TX_DELAY_MASK, .rx_delay_mask = CLK_V2_RX_DELAY_MASK, .always_on = CLK_V2_ALWAYS_ON, + .adjust = SD_EMMC_ADJUST, }; static const struct meson_mmc_data meson_axg_data = { .tx_delay_mask = CLK_V3_TX_DELAY_MASK, .rx_delay_mask = CLK_V3_RX_DELAY_MASK, .always_on = CLK_V3_ALWAYS_ON, + .adjust = SD_EMMC_V3_ADJUST, }; static const struct of_device_id meson_mmc_of_match[] = {