From patchwork Wed Mar 20 17:48:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 10862347 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 8C846139A for ; Wed, 20 Mar 2019 17:48:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6787629E40 for ; Wed, 20 Mar 2019 17:48:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58BEB29E4A; Wed, 20 Mar 2019 17:48: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_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable 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 11B0529E5D for ; Wed, 20 Mar 2019 17:48: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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=Tk1YIDuWav1jchrkIoYw4fZofwsTsbBooCTjdNf1jlk=; b=rAUQFl/KKvpk3PLMm+kUds0dxO wY34RDZWba2yc+TSHkowGtOZcvQFl5kCvKvPTj9tmEnK/so1oTgB6veMH+ERhN/6gz6/WcnIKa9vM LspXvs85YdkcsdNJFWzFWeC3WlmC5rhWWhAyb4wxcrkMOn3KLMt1cZf6itvS1ZBHqEwmaBVVUrjtc b3/QruLOjqgPGkb70XL76hu2mpYkUJFe0KuC0pRdSR4BLkcKGwjUyjkl55bhgSIsCwQ76m69m6u3E yUGRBgMWJiZnkuhGZ5cIYLO2EbVGu9Mc8E0JpPybEMnoa/nlkmwrfZrsncNFcfbI2fbadylvv8vxR VmQlz4Eg==; 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 1h6fKa-00076T-8f; Wed, 20 Mar 2019 17:48:48 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6fKD-0006YA-Gp; Wed, 20 Mar 2019 17:48:27 +0000 Received: by mail-lf1-x141.google.com with SMTP id u9so2527911lfe.11; Wed, 20 Mar 2019 10:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0E6xQZ+auWvet4Xcp79XBuUAWGpSmBQziO8fsTek7SA=; b=WAuQEzpGuPs6NFILtsb1ghIJPeE7TA7gryuq7o2f+YMsMVnT5wwYD2mNSdwpwmO4Lw GK/Nm5cy++oAMnbntXq9Os+V8prBDtscoiw0/6Nky8oTx8r5pck2LljHO+tO2C4lerlf dsEXHoyy8N/fKgDpd4+4zo48jWYv7Wd6+MHcWsCvZiFY+qdGKkkHe5/8SWEyN0CiFk+Q OQHcTWTD2hK00jP9uC8gM0NuYb54HalDlrtrvP++Triwely2oODVsRZlMCVLcOPE8oQP AKfPkW2BoXCau3TAd7G1qF32pq4Gd441PSbsayBfhEmI3nB2Nhe3OQVHFdHmJYSsVLfz MAbg== 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; bh=0E6xQZ+auWvet4Xcp79XBuUAWGpSmBQziO8fsTek7SA=; b=MatBSODDmwxkMLNmgF0xT9NW2BUiyKMDWzW4erRZBM59HhCN/r1nvfA0VzM/qeIcMR D5FAsfOz2izN/UfzxGea9EXU33is/yMOgoQYh0GD9Imelk17TlLWbrbPlTXuBjR23/1h Cmq6T9Iu3ArLX3ojZGS/v/2C2cNohXyx76KxoepZd78tOcnvuzLhJrMWrY2EbvB/5F6H I30Of9tbT+0xvWRmqyQyqPZ17lsyT/S4kbhKFhHLCEmIAu+Y4n5MEcU8dZvimvxCC2JJ sa6p9ovBKloLXt4D97DQDUjvQyOWv4hyMJnVZWJj5MGdex8BZTa4//WGuNYT2czzMJUl oK8A== X-Gm-Message-State: APjAAAVXjEWfk8MWjJ/dMTYqg3uTStH2gOZDNB3fYV9nSeVjh6TeM5pl Dpeg38tZPxg2+eQe87kpYVw= X-Google-Smtp-Source: APXvYqztN7jsAEaMxsvSCIAP5Y7C6hLZ8itdssoOAfIgoR8Wmsn+ea7gdoZl9nAe/a4U47u+WmwKUg== X-Received: by 2002:a19:5217:: with SMTP id m23mr16664029lfb.19.1553104103535; Wed, 20 Mar 2019 10:48:23 -0700 (PDT) Received: from ubuntu.lintech.local ([80.87.144.137]) by smtp.gmail.com with ESMTPSA id m19sm479959lfb.78.2019.03.20.10.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 10:48:23 -0700 (PDT) From: Alexander Kochetkov To: Jaehoon Chung , Ulf Hansson , Heiko Stuebner , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mmc: dw_mmc-rockchip: fix transfer hangs on rk3188 Date: Wed, 20 Mar 2019 20:48:05 +0300 Message-Id: <1553104085-32312-3-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1553104085-32312-1-git-send-email-al.kochet@gmail.com> References: <1553104085-32312-1-git-send-email-al.kochet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190320_104825_564365_04DEED8C X-CRM114-Status: GOOD ( 17.11 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Kochetkov MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP I've found that sometimes dw_mmc in my rk3188 based board stop transfer any data with error: kernel: dwmmc_rockchip 1021c000.dwmmc: Unexpected command timeout, state 3 Further digging into problem showed that sometimes one of EDMA-based transfers hangs and abort with HTO error. I've made test, that 100% reproduce the error. I found, that setting max_segs parameter to 1 fix the problem. I guess the problem is hardware related and relates to DMA controller implementation for rk3188. Probably it can relates to missed FLUSHP, see commit 271e1b86e691 ("dmaengine: pl330: add quirk for broken no flushp"). It is possible that pl330 and dw_mmc become out of sync then pl330 driver switch from one scatterlist to another. If we limit scatterlist size to 1, we can avoid switching scatterlists and avoid hardware problem. Setting max_segs to 1 tells mmc core to use maximum one scatterlist for one transfer. I guess that all other rk3xxx chips that lacks FLUSHP also affected by the problem. So I made fix for all rk3xxx chips from rk2928 to rk3188. Signed-off-by: Alexander Kochetkov --- drivers/mmc/host/dw_mmc-rockchip.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c index 8c86a80..2eed922 100644 --- a/drivers/mmc/host/dw_mmc-rockchip.c +++ b/drivers/mmc/host/dw_mmc-rockchip.c @@ -292,6 +292,24 @@ static int dw_mci_rk3288_parse_dt(struct dw_mci *host) return 0; } +static void dw_mci_rk2928_init_slot(struct dw_mci *host) +{ + struct mmc_host *mmc = host->slot->mmc; + + if (host->use_dma == TRANS_MODE_EDMAC) { + /* + * Using max_segs > 1 leads to rare EDMA transfer hangs + * resulting in HTO errors. + */ + mmc->max_segs = 1; + mmc->max_blk_size = 65535; + mmc->max_blk_count = 64 * 512; + mmc->max_req_size = + mmc->max_blk_size * mmc->max_blk_count; + mmc->max_seg_size = mmc->max_req_size; + } +} + static int dw_mci_rockchip_init(struct dw_mci *host) { /* It is slot 8 on Rockchip SoCs */ @@ -314,6 +332,7 @@ static int dw_mci_rockchip_init(struct dw_mci *host) static const struct dw_mci_drv_data rk2928_drv_data = { .init = dw_mci_rockchip_init, + .init_slot = dw_mci_rk2928_init_slot, }; static const struct dw_mci_drv_data rk3288_drv_data = {