From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19944E7C4D0 for ; Wed, 4 Oct 2023 15:27:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54AC48D002C; Wed, 4 Oct 2023 11:27:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D3768D0027; Wed, 4 Oct 2023 11:27:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34E8E8D002C; Wed, 4 Oct 2023 11:27:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 234EB8D0027 for ; Wed, 4 Oct 2023 11:27:25 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D886EB3EFF for ; Wed, 4 Oct 2023 15:27:24 +0000 (UTC) X-FDA: 81308158008.08.192DD3F Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf11.hostedemail.com (Postfix) with ESMTP id E3E7840011 for ; Wed, 4 Oct 2023 15:27:21 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf11.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696433242; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7+vH9ZjDJZ1+GqxJ7pOb8CHx+0pluQ1FP46Flmdef0g=; b=qHUDbd3/994WlmpKXQ2awtoxE5SEeNt2It5BlHYI0UnwnRj/ysBGKqtAlaSgd6rhDihBTW Hs6u/JKq6V5Yidv7CH0xFWnfeXbgYASmJKSLIkWyCKTdF4vYxu4IAxn3rmLShy7kGgeBQx N21IL9Sj+DBgHkX0NS7RMRGkutvlQTc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf11.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696433242; a=rsa-sha256; cv=none; b=sDvsBUO81cj1zm6YaUfvbmyxtc4r/FshGaVDu0KAxzwDxG9UcJLDV19w7E4Fu5H0RTAAkR UtiLLG32VIYIQ/azBkgg5YQtcE3f61f8QKlS2/7eEe/8CHYEi6GMVy3zotEiNOppfoTXYD YDLweASLF5nTYh0S8xTkfmAAD5lm0mI= Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-5a2536adaf3so27553127b3.2 for ; Wed, 04 Oct 2023 08:27:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696433241; x=1697038041; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7+vH9ZjDJZ1+GqxJ7pOb8CHx+0pluQ1FP46Flmdef0g=; b=FNat2ZGofxWHtNLpQCvLr7RxnxGg0n5oJIROwjvYZE/dXqFKwOoHIAGk2FtsXuhlMO Yxel8etyLHFQnw1QAd9PUCNPdW8YgutEig4vjXaBqKjihhsizyCra6VlrCZwAx60dZgO VWiAXafMRQwaiOMI0c2xXqqfvExAdPqU3a2a0HZRUqD9aFaYQi6MxI2huAPGiMWE8m/R 0JAYjz8btjSgRg03m3tDvie6g/XtNLht7XhaXwrGl2HXj0Fh+mXSK1p2xxegZOhRpnUR 477Lnsg1DDbFbmoj2WiFfhX1ZhbrscA41kq+dvfQXmhV1a1Jo3YXXqOUFZaAClgPfbwM BDlg== X-Gm-Message-State: AOJu0Yw7dfVm2yMGRcKjWeZW5FhPqI1XBmUYDbKlK23Y8jAm3XHRdy5y 0ecOimAzigHc9Y/iQu/VgtmTHk6WdAdM4g== X-Google-Smtp-Source: AGHT+IFhnD2b593fU5ipJsOb96u62+QFFrhX68/9zFXyCMP/5WRpSrzS6MOxhIh3GlVzJMHyuBxoEA== X-Received: by 2002:a0d:c8c3:0:b0:59b:f8da:ffdb with SMTP id k186-20020a0dc8c3000000b0059bf8daffdbmr3027734ywd.29.1696433240670; Wed, 04 Oct 2023 08:27:20 -0700 (PDT) Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com. [209.85.128.181]) by smtp.gmail.com with ESMTPSA id f188-20020a0dc3c5000000b00570599de9a5sm1209106ywd.88.2023.10.04.08.27.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Oct 2023 08:27:20 -0700 (PDT) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-59f1dff5298so27455367b3.3 for ; Wed, 04 Oct 2023 08:27:19 -0700 (PDT) X-Received: by 2002:a0d:d7cc:0:b0:584:4bbb:963b with SMTP id z195-20020a0dd7cc000000b005844bbb963bmr2800485ywd.15.1696433239582; Wed, 04 Oct 2023 08:27:19 -0700 (PDT) MIME-Version: 1.0 References: <20230921-th1520-mmc-v1-0-49f76c274fb3@baylibre.com> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 4 Oct 2023 17:27:06 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/6] RISC-V: Add eMMC support for TH1520 boards To: Jisheng Zhang Cc: Robin Murphy , "Lad, Prabhakar" , Drew Fustini , Christoph Hellwig , Lad Prabhakar , Robert Nelson , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Adrian Hunter , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Jason Kridner , Xi Ruoyao , Han Gao , Icenowy Zheng , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Alexandre Ghiti , Linux-MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: E3E7840011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: p18rtg6rdbeebch4okfjs5hhjw8priw4 X-HE-Tag: 1696433241-695912 X-HE-Meta: U2FsdGVkX1+8NQkJLnGjsA2b9/3HFW/o08a6p88QGkhxQbSyL+h3UTONHZ+buX+WtbLyNyFcCM7eLc/R3/DEmVlMZQapMf0Sfox6YNR4+TFy2/XZRUM8L4blJglBnsLiv8BU9rEewZi84diGVHXbd1NyfNjN0/NSAS006TwJQVoZpx2jofTfUS3/0qgFLj9AJf24cDDIFvEoolST5NbE2fR9QFG3uFB5c45lmVH6Es5W5toCDQV5NMOeigsALxXK2++p4RBxHdHKmZx167wOZlrNkYLyo7a3/pX/jYq+HraoCNAgdHw4IWNCAQqgahifPEB387OtvxqPLJeUEsqxGsAKae2EwgCRyX6BjW/iaNc3fbOeKjL7WFeRdbmweeQ3jtF5362Y5VjtDY8IS3ubQNUIWR1iHaOfo/9jYpWgeraylep8wgKnVk5hurUXvORDfqvo61RlLgFIFvBnLIS8cwDym/L7Yro35NLvKuozTFPdJxw9pMEehBmXOy+m7M/X5wSAkOqwbc4zVG2YTycwVvCFfZJGYX+aYf8ZDupOIeBghZSguRYIvIFo2qnrQIJqWX6HAe/zbDpGE/5OouNXs6z8wH/hF4XqM2QS2cmLO8oha+x+0LbXl/ztHl3t6goIk0n5NiRA7AWhVIqW+C5QEm/VxptW7e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9R60KDJcJsrMKMg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Jisheng, On Wed, Oct 4, 2023 at 4:18=E2=80=AFPM Jisheng Zhang w= rote: > On Wed, Oct 04, 2023 at 02:49:56PM +0100, Robin Murphy wrote: > > On 04/10/2023 2:02 pm, Lad, Prabhakar wrote: > > > + CC linux-mm and Robin Murphy > > > > > > On Wed, Oct 4, 2023 at 12:42=E2=80=AFPM Jisheng Zhang wrote: > > > > > > > On Mon, Oct 02, 2023 at 09:37:44PM -0700, Drew Fustini wrote: > > > > > On Fri, Sep 22, 2023 at 05:48:21PM -0500, Robert Nelson wrote: > > > > > > On Fri, Sep 22, 2023 at 2:08=E2=80=AFPM Robert Nelson wrote: > > > > > > > > > > > > > > On Thu, Sep 21, 2023 at 8:51=E2=80=AFPM Drew Fustini wrote: > > > > > > > > > > > > > > > > This series adds support for the eMMC on the BeagleV Ahead = and the > > > > > > > > Sipeed LicheePi 4A. This allows the kernel to boot with the= rootfs on > > > > > > > > eMMC. > > > > > > > > > > > > > > > > I tested on top of v6.6-rc2 with this config [1]. I was abl= e to boot > > > > > > > > both the Ahead [2] and LPi4a [3] from eMMC. The following p= rerequisites > > > > > > > > are required: > > > > > > > > > > > > > > > > [PATCH v2] riscv: dts: thead: set dma-noncoherent to soc= bus [4] > > > > > > > > > > > > > > > > I pushed a branch [5] with this patch series and the above = patch for > > > > > > > > those that find a git branch easier to test. > > > > > > > > > > > > > > > > Please note that only the MMC controller connected to the e= MMC device > > > > > > > > is enabled in the device trees for these two boards. I did = not yet > > > > > > > > attempt to configure and use the microSD card slot. My pref= erence is to > > > > > > > > address that in a future patch series. > > > > > > > > > > > > > > > > References: > > > > > > > > [1] https://gist.github.com/pdp7/5fbdcf2a65eb1abdd3a29d519c= 19cdd2 > > > > > > > > [2] https://gist.github.com/pdp7/91a801a5f8d1070c53509eda98= 00ad78 > > > > > > > > [3] https://gist.github.com/pdp7/1445c3c991e88fd69c60165cef= 65726a > > > > > > > > [4] https://lore.kernel.org/linux-riscv/20230912072232.2455= -1-jszhang@kernel.org/ > > > > > > > > [5] https://github.com/pdp7/linux/tree/b4/th1520-mmc > > > > > > > > > > > > > > This patchset came out very nice! > > > > > > > > > > > > > > v6.6-rc2 with Last RFC v2: > > > > > > > > > > > > > > [ 4.066630] mmc0: SDHCI controller on ffe7080000.mmc > > > > > > > [ffe7080000.mmc] using PIO > > > > > > > > > > > > > > debian@BeagleV:~$ sudo hdparm -tT /dev/mmcblk0 > > > > > > > > > > > > > > /dev/mmcblk0: > > > > > > > Timing cached reads: 1516 MB in 2.00 seconds =3D 758.09 = MB/sec > > > > > > > Timing buffered disk reads: 84 MB in 3.01 seconds =3D 27= .94 MB/sec > > > > > > > > > > > > > > vs v6.6-rc2 with this patchset: > > > > > > > > > > > > > > [ 4.096837] mmc0: SDHCI controller on ffe7080000.mmc > > > > > > > [ffe7080000.mmc] using DMA > > > > > > > > > > > > > > debian@BeagleV:~$ sudo hdparm -tT /dev/mmcblk0 > > > > > > > > > > > > > > /dev/mmcblk0: > > > > > > > Timing cached reads: 1580 MB in 2.00 seconds =3D 790.97 = MB/sec > > > > > > > Timing buffered disk reads: 418 MB in 3.00 seconds =3D 139= .11 MB/sec > > > > > > > > > > > > Drew pointed out on Slack, this was not quite right.. After mor= e > > > > > > digging by Drew, CONFIG_DMA_GLOBAL_POOL is causing a DMA limita= tion > > > > > > with the multiplatform defconfig. so with, > > > > > > > > > > > > ./scripts/config --disable CONFIG_ARCH_R9A07G043 > > > > > > > > > > > > (to remove CONFIG_DMA_GLOBAL_POOL)... another 2x in buffered re= ads.. > > > > > > > > > > > > [ 4.059242] mmc0: SDHCI controller on ffe7080000.mmc > > > > > > [ffe7080000.mmc] using ADMA 64-bit > > > > > > > > > > > > debian@BeagleV:~$ sudo hdparm -tT /dev/mmcblk0 > > > > > > > > > > > > /dev/mmcblk0: > > > > > > Timing cached reads: 1600 MB in 2.00 seconds =3D 800.93 MB= /sec > > > > > > Timing buffered disk reads: 892 MB in 3.00 seconds =3D 297.0= 6 MB/sec > > > > > > > > > > It seems CONFIG_DMA_GLOBAL_POOL=3Dy causes ADMA buffer alloc to f= ail [1]: > > > > > > > > > > mmc0: Unable to allocate ADMA buffers - falling back to standa= rd DMA > > > > > > > > > > Prabhakar's AX45MP non-coherent DMA support [2] series introduced= the > > > > > selection of DMA_GLOBAL_POOL for ARCH_R9A07G043 and the riscv def= config > > > > > selects ARCH_R9A07G043. > > > > > > > > > > Patch 5 in the series [3] states that: > > > > > > > > > > With DMA_GLOBAL_POOL enabled all DMA allocations happen from t= his > > > > > region and synchronization callbacks are implemented to synchr= onize > > > > > when doing DMA transactions. > > > > > > > > > > This example of a "shared-dma-pool" node was given: > > > > > > > > > > pma_resv0@58000000 { > > > > > compatible =3D "shared-dma-pool"; > > > > > reg =3D <0x0 0x58000000 0x0 0x08000000>; > > > > > no-map; > > > > > linux,dma-default; > > > > > }; > > > > > > > > > > I've copied that to th1520-beaglev-ahead.dts. The address of 0x58= 000000 > > > > > has no significance on th1520, but the existence of shared-dma-po= ol > > > > > seems to fix the problem. ADMA mode [4] is now working even thoug= h > > > > > CONFIG_DMA_GLOBAL_POOL=3Dy. > > > > > > > > + Christoph, Lad > > > > > > > > IMHO, this is not TH1520 specific but a generic issue. > > > > > > > > I believe commit 484861e09f3e ("soc: renesas: Kconfig: Select the > > > > required configs for RZ/Five SoC") can cause regression on all > > > > non-dma-coherent riscv platforms with generic defconfig. This is > > > > a common issue. The logic here is: generic riscv defconfig selects > > > > ARCH_R9A07G043 which selects DMA_GLOBAL_POOL, which assumes all > > > > non-dma-coherent riscv platforms have a dma global pool, this assum= ption > > > > seems not correct. And I believe DMA_GLOBAL_POOL should not be > > > > selected by ARCH_SOCFAMILIY, instead, only ARCH under some specific > > > > conditions can select it globaly, for example NOMMU ARM and so on. > > > > > > > > Since this is a regression, what's proper fix? any suggestion is > > > > appreciated. > > > > I think the answer is to not select DMA_GLOBAL_POOL, since that is only > > designed for nommu cases where non-cacheable memory lives in a fixed pl= ace > > in the physical address map, and regular kernel pages can't be remapped= . As > > far as I'm aware, RISCV_DMA_NONCOHERENT is the thing you want, such tha= t > > DMA_DIRECT_REMAP can dynamically provide non-cacheable coherent buffers= for > > non-hardware-coherent devices. > > Thank Robin! > AFAIK, ARCH_R9A07G043 needs the dma global pool to handle its CMO. So > it looks like ARCH_R9A07G043 can't be enabled in riscv generic > defconfig. And we also need a special solution to prevent random config > from selecting ARCH_R9A07G043 by chance for other platforms There will be a similar issue with e.g. Starlight, as ERRATA_STARFIVE_JH710= 0 (not yet upstream, but in esmil/visionfive) also selects DMA_GLOBAL_POOL. Gr{oetje,eeting}s, Geert --=20 Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org In personal conversations with technical people, I call myself a hacker. Bu= t when I'm talking to journalists I just say "programmer" or something like t= hat. -- Linus Torvalds