Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp466713yba; Wed, 15 May 2019 04:37:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrTn97YuS5abFhEOjdO+wrPQwsseez+k7Iayf/li9P1jRL+DCsvJ5CvylRCiJdUwcqVLwf X-Received: by 2002:a63:fb02:: with SMTP id o2mr42556443pgh.357.1557920244804; Wed, 15 May 2019 04:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920244; cv=none; d=google.com; s=arc-20160816; b=X9CyF8PpBpnwheVS4TwOEtUmZZrzHRY+i/j2meTOpkZ5RqLK+3RDS/qQOcWdQjPOoS ndtTu3xyekYw7B8LK5zO1jSBp1eftjargGuOceGnfJC0a3Uy28U+S3U1DvBvhJWQ2HxT 49AYrDxSTm0AiUtsgnQrOgkoZXxMBkdQbSp3iTsUKbOdcwlGK/ETrGITizUFkZ2x0Zz+ r42A0GZL/7g9UKFNMS8DSkFZP9RFH1nbO4CpERxDyUUdUilnWLNFkBIwNQOqvEbSJNYS 8aiaPR2OqVbND99EYl/0lFM5hcPPH3GXR9XWPELlcYEC/4xHAO0aoM9ha/R/mmv1R6N6 OPxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZWqAGCI5yMJx23kt3Mfd3kN55xmuwLQAWVG8F0xyeaE=; b=OSvGdEKkPktGFuyf6uSxkmxnvhOW/b/S3ex3KLBteLFEDnk8EaphJbtPhhQSbNbxP7 xob1NapeZam3pS2L3ubDNuBWKlj9IyfZLmN8FzgfWABUXVwkazT6qviH2H8sGstugLpd DOeq98kCA1AUmD5MPePeF+QSCJRqkleLq/jOVYMgG7NLxxlF36hupKjQcVvBtLd+bVNd 3JEpkvynsMDOdH1xGNTthueZb4Qy0aTqN7lo7bxpvnjRXCV76iSIBMYCfU+R0CcBdQr4 O+havyfnZdxtVTJm9hKQsCY1Lie146mxBxReP0TwVbb4qlcQKVQNIljfKBA3ZIseqXqb 5V1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H8I82c78; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si1581532pgb.464.2019.05.15.04.37.09; Wed, 15 May 2019 04:37:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H8I82c78; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733095AbfEOLfO (ORCPT + 99 others); Wed, 15 May 2019 07:35:14 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:43582 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbfEOLfN (ORCPT ); Wed, 15 May 2019 07:35:13 -0400 Received: by mail-vs1-f66.google.com with SMTP id d128so1440238vsc.10 for ; Wed, 15 May 2019 04:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZWqAGCI5yMJx23kt3Mfd3kN55xmuwLQAWVG8F0xyeaE=; b=H8I82c784m0jGWAdSgfv70xt5W/e2W1AydqnX4HmVv/TyjugE8NKbcb1hozMQxpxXA 2DMvnzUlpl5Z1ddBvv2j5+QHYXWqvRQEFmf36SjeHZ6L+5iZOIw1vd3+5EkGfiyLlQ9i 15zeYIjV3z+qqaNh0MOrCDWQbxw713gfubMr5pupFHsP8XOl4YSYRWbcAC8N06GjUEU/ Lr96fSdftzVvoCVyjH52mglkTzdVXx8RxOwGFH0TnFCIwyZWT+XGaNw5B6DHuoZzAiUW BKddH9aLOjw/edqV2fNVOwoMJ1m+Nq21PbvSIoFwQbfjNBmlfngrPtntXUGB2/yrjQI+ r0FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZWqAGCI5yMJx23kt3Mfd3kN55xmuwLQAWVG8F0xyeaE=; b=pUP/wr+KzFpqMVc8pDZOWoZhlKo8NWBfWT8/KNmexw7bIMDHuTZDpj5fZkHJhixIUz zQnqFollWdIOfL5ygpRje9up7Ho78yyhTyahxMmn2Qz7z8F9NQOsySXYLIIn7a4RPE5d K0jbuWmrGWkDQffiqX9G5tYspMu6tpRNpr7U4wJOLPcXHJatgswNgDRCOB38LxEyEHIO FLPUddewyG/dUtXvhnGnNCnchzqz2UqciDQyzX0rQ6G3LenFyTK6aqKQmFpiCdb0UIUG 5BIRW1AiNQPfqhWECHT9by6W1jIs0aZ5wBjfcIwZ/Dx7E6ZFHNMBdfK66GJUMP72yLNg dkaw== X-Gm-Message-State: APjAAAUB/7uU7TKOj4nBDoWw0vrUUcEAKid9bFX2ejpyBUlkBMaZzasN rcVT56uFZjBvm7LbIMWJkzuu+VefyQNEotqB/zrnJA== X-Received: by 2002:a67:c987:: with SMTP id y7mr20082008vsk.35.1557920111662; Wed, 15 May 2019 04:35:11 -0700 (PDT) MIME-Version: 1.0 References: <20190513091548.16674-1-narmstrong@baylibre.com> <20190513091548.16674-3-narmstrong@baylibre.com> In-Reply-To: <20190513091548.16674-3-narmstrong@baylibre.com> From: Ulf Hansson Date: Wed, 15 May 2019 13:34:35 +0200 Message-ID: Subject: Re: [PATCH 2/3] mmc: meson-gx: add ddr-access-quirk To: Neil Armstrong Cc: Kevin Hilman , baylibre-upstreaming@groups.io, "linux-mmc@vger.kernel.org" , "open list:ARM/Amlogic Meson..." , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 May 2019 at 11:16, Neil Armstrong wrote: > > On the Amlogic G12A SoC family, (only) the SDIO controller fails to access > the data from DDR, leading to a broken controller. Could you possibly make it more clear that this is about the internal DMA support in the controller that is broken? Did you consider to use the controller without using the DMA mode? Is that possible? > > But each MMC controller has 1,5KiB of SRAM after the registers, that can > be used as bounce buffer to avoid direct DDR access from the integrated > DMAs (this SRAM may be used by the boot ROM when DDR is not yet initialized). I think "DDR" is a confusing terminology, that goes for the DT binding as well. What about using "DRAM" instead? In any case, using the SRAM seems like it could work. However, just so I get this right, it solely dedicated to the SDIO controller or may someone else also try to use it? > > The quirk is to disable the chained descriptor for this controller, and > use this SRAM memory zone as buffer for the bounce buffer fallback mode. > > The performance hit hasn't been evaluated, but the fix has been tested > using a WiFi AP6398S SDIO module, and the iperf3 Bandwidth measurement gave > 55.2 Mbits/sec over a 63 Hours long test, with the SDIO ios set as High-Speed > at 50MHz clock. It gave 170 Mbits/sec as SDR104 and 200MHz clock. If possible to not use DMA, it would be interesting to compare numbers. :-) > > Signed-off-by: Neil Armstrong > --- > drivers/mmc/host/meson-gx-mmc.c | 65 ++++++++++++++++++++++++++------- > 1 file changed, 52 insertions(+), 13 deletions(-) > > diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c > index c5a8af4ca76b..6ef465304052 100644 > --- a/drivers/mmc/host/meson-gx-mmc.c > +++ b/drivers/mmc/host/meson-gx-mmc.c > @@ -129,6 +129,9 @@ > #define SD_EMMC_TXD 0x94 > #define SD_EMMC_LAST_REG SD_EMMC_TXD > > +#define SD_EMMC_SRAM_DATA_BUF_LEN 1536 > +#define SD_EMMC_SRAM_DATA_BUF_OFF 0x200 > + > #define SD_EMMC_CFG_BLK_SIZE 512 /* internal buffer max: 512 bytes */ > #define SD_EMMC_CFG_RESP_TIMEOUT 256 /* in clock cycles */ > #define SD_EMMC_CMD_TIMEOUT 1024 /* in ms */ > @@ -168,6 +171,8 @@ struct meson_host { > unsigned long req_rate; > bool ddr; > > + bool ddr_access_quirk; > + > struct pinctrl *pinctrl; > struct pinctrl_state *pins_default; > struct pinctrl_state *pins_clk_gate; > @@ -232,11 +237,20 @@ static struct mmc_command *meson_mmc_get_next_command(struct mmc_command *cmd) > static void meson_mmc_get_transfer_mode(struct mmc_host *mmc, > struct mmc_request *mrq) > { > + struct meson_host *host = mmc_priv(mmc); > struct mmc_data *data = mrq->data; > struct scatterlist *sg; > int i; > bool use_desc_chain_mode = true; > > + /* > + * When Controller DMA cannot directly access DDR memory, disable > + * support for Chain Mode to directly use the internal SRAM using > + * the bounce buffer mode. > + */ > + if (host->ddr_access_quirk) > + return; > + > /* > * Broken SDIO with AP6255-based WiFi on Khadas VIM Pro has been > * reported. For some strange reason this occurs in descriptor > @@ -1049,6 +1063,10 @@ static int meson_mmc_probe(struct platform_device *pdev) > host->dev = &pdev->dev; > dev_set_drvdata(&pdev->dev, host); > > + /* The G12A SDIO Controller needs an SRAM bounce buffer */ > + host->ddr_access_quirk = device_property_read_bool(&pdev->dev, > + "amlogic,ddr-access-quirk"); > + > /* Get regulators and the supported OCR mask */ > host->vqmmc_enabled = false; > ret = mmc_regulator_get_supply(mmc); > @@ -1146,9 +1164,16 @@ static int meson_mmc_probe(struct platform_device *pdev) > goto err_init_clk; > > mmc->caps |= MMC_CAP_CMD23; > - mmc->max_blk_count = CMD_CFG_LENGTH_MASK; > + if (host->ddr_access_quirk) { > + /* Limit to the available sram memory */ > + mmc->max_segs = SD_EMMC_SRAM_DATA_BUF_LEN / mmc->max_blk_size; > + mmc->max_blk_count = mmc->max_segs; > + } else { > + mmc->max_blk_count = CMD_CFG_LENGTH_MASK; > + mmc->max_segs = SD_EMMC_DESC_BUF_LEN / > + sizeof(struct sd_emmc_desc); > + } > mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; > - mmc->max_segs = SD_EMMC_DESC_BUF_LEN / sizeof(struct sd_emmc_desc); > mmc->max_seg_size = mmc->max_req_size; > > /* > @@ -1158,15 +1183,27 @@ static int meson_mmc_probe(struct platform_device *pdev) > */ > mmc->caps2 &= ~MMC_CAP2_HS400; > > - /* data bounce buffer */ > - host->bounce_buf_size = mmc->max_req_size; > - host->bounce_buf = > - dma_alloc_coherent(host->dev, host->bounce_buf_size, > - &host->bounce_dma_addr, GFP_KERNEL); > - if (host->bounce_buf == NULL) { > - dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n"); > - ret = -ENOMEM; > - goto err_free_irq; > + if (host->ddr_access_quirk) { > + /* > + * The MMC Controller embeds 1,5KiB of internal SRAM > + * that can be used to be used as bounce buffer. > + * In the case of the G12A SDIO controller, use these > + * instead of the DDR memory > + */ > + host->bounce_buf_size = SD_EMMC_SRAM_DATA_BUF_LEN; > + host->bounce_buf = host->regs + SD_EMMC_SRAM_DATA_BUF_OFF; > + host->bounce_dma_addr = res->start + SD_EMMC_SRAM_DATA_BUF_OFF; > + } else { > + /* data bounce buffer */ > + host->bounce_buf_size = mmc->max_req_size; > + host->bounce_buf = > + dma_alloc_coherent(host->dev, host->bounce_buf_size, > + &host->bounce_dma_addr, GFP_KERNEL); > + if (host->bounce_buf == NULL) { > + dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n"); > + ret = -ENOMEM; > + goto err_free_irq; > + } > } > > host->descs = dma_alloc_coherent(host->dev, SD_EMMC_DESC_BUF_LEN, > @@ -1208,8 +1245,10 @@ static int meson_mmc_remove(struct platform_device *pdev) > > dma_free_coherent(host->dev, SD_EMMC_DESC_BUF_LEN, > host->descs, host->descs_dma_addr); > - dma_free_coherent(host->dev, host->bounce_buf_size, > - host->bounce_buf, host->bounce_dma_addr); > + > + if (!host->ddr_access_quirk) > + dma_free_coherent(host->dev, host->bounce_buf_size, > + host->bounce_buf, host->bounce_dma_addr); > > clk_disable_unprepare(host->mmc_clk); > clk_disable_unprepare(host->core_clk); > -- > 2.21.0 > Kind regards Uffe