Linux-Amlogic Archive on lore.kernel.org
 help / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: ulf.hansson@linaro.org, baylibre-upstreaming@groups.io,
	khilman@baylibre.com, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/3] mmc: meson-gx: add ddr-access-quirk
Date: Thu, 16 May 2019 11:09:55 +0200
Message-ID: <65c704a4-c4b7-ebdd-a869-353b1536410f@baylibre.com> (raw)
In-Reply-To: <CAFBinCCtNQmKKL8yw07DKOfPK=eusgCuYeBmwgiHm0SSVmuFPQ@mail.gmail.com>

On 15/05/2019 23:18, Martin Blumenstingl wrote:
> Hi Neil,
> 
> On Wed, May 15, 2019 at 2:45 PM Neil Armstrong <narmstrong@baylibre.com> wrote:
>>
>> On 14/05/2019 19:58, Martin Blumenstingl wrote:
>>> Hi Neil,
>>>
>>> On Mon, May 13, 2019 at 11:16 AM Neil Armstrong <narmstrong@baylibre.com> wrote:
>>> [...]
>>>> @@ -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;
>>> I'm curious: why do you need to set bounce_dma_addr in this case?
>>
>> We still need the physical bounce buffer address since we write in the registers,
> so writing bounce_dma_addr to SD_EMMC_CMD_DAT is needed to make it work?
> 
>> and we need the logical address to memcpy() in the buffer.
> as far as I understand that is what we use the "bounce_buf" member
> for, but I don't see why we need "bounce_dma_addr"

Sorry I don't understand these questions, I haven't changed the
bounce buffer behavior here, I only make it use a local SRAM buffer
instead of an dma_alloc_coherent() allocated buffer.

Having bounce_buf_size/bounce_buf/bounce_dma_addr is still necessary like
an allocated buffer.

> 
>>>
>>>> +       } 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,
>>> if host->descs cannot be allocated then you need to conditionally skip
>>> dma_free_coherent for the bounce buffer in the goto err_bounce_buf
>>> case a few lines below (just like you did in meson_mmc_remove)
>>
>> It can be allocated, it's only useless. I can skip it but I don't want
>> to break any logic in the driver.
> I wasn't clear in my last email, I meant this error case:
>   err_bounce_buf:
>     dma_free_coherent(host->dev, host->bounce_buf_size, ...
> when host->ddr_access_quirk is true then you skip the
> dma_alloc_coherent call for bounce_buf

Oh, ok, yes, I'll add it.

Neil

> 
> 
> Martin
> 


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply index

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13  9:15 [PATCH 0/3] mmc: meson-gx: add ddr-access-quirk support Neil Armstrong
2019-05-13  9:15 ` [PATCH 1/3] dt-bindings: mmc: meson-gx: add ddr-access-quirk property Neil Armstrong
2019-05-14 17:50   ` Martin Blumenstingl
2019-05-15 12:43     ` Neil Armstrong
2019-05-15 11:37   ` Ulf Hansson
2019-05-15 12:43     ` Neil Armstrong
2019-05-13  9:15 ` [PATCH 2/3] mmc: meson-gx: add ddr-access-quirk Neil Armstrong
2019-05-13 17:47   ` Kevin Hilman
2019-05-14 17:58   ` Martin Blumenstingl
2019-05-15 12:45     ` Neil Armstrong
2019-05-15 21:18       ` Martin Blumenstingl
2019-05-16  9:09         ` Neil Armstrong [this message]
2019-05-15 11:34   ` Ulf Hansson
2019-05-15 12:51     ` Neil Armstrong
2019-05-13  9:15 ` [PATCH 3/3] arm64: dts: meson-g12a: add ddr-access-quirk property to SDIO controller Neil Armstrong
2019-05-14 17:51   ` Martin Blumenstingl
2019-05-13  9:58 ` [PATCH 0/3] mmc: meson-gx: add ddr-access-quirk support Jerome Brunet
2019-05-13 11:28   ` Jerome Brunet
2019-05-14  9:14 ` [baylibre-upstreaming] " guillaume La Roque

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65c704a4-c4b7-ebdd-a869-353b1536410f@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=baylibre-upstreaming@groups.io \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Amlogic Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-amlogic/0 linux-amlogic/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-amlogic linux-amlogic/ https://lore.kernel.org/linux-amlogic \
		linux-amlogic@lists.infradead.org linux-amlogic@archiver.kernel.org
	public-inbox-index linux-amlogic


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-amlogic


AGPL code for this site: git clone https://public-inbox.org/ public-inbox