qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qianfanguijin@163.com, qemu-arm@nongnu.org,
	qemu-devel@nongnu.org,
	"Strahinja Jankovic" <strahinja.p.jankovic@gmail.com>,
	"Beniamino Galvani" <b.galvani@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>
Subject: Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Date: Sat, 24 Jun 2023 08:02:04 -0700	[thread overview]
Message-ID: <01087628-44c0-2b15-61bc-8677b7d1b459@roeck-us.net> (raw)
In-Reply-To: <a51c71c5-4c5e-8723-76f1-2cc9410f601b@roeck-us.net>

On 6/24/23 07:23, Guenter Roeck wrote:
> On 6/24/23 03:40, Peter Maydell wrote:
>> On Fri, 23 Jun 2023 at 20:33, Guenter Roeck <linux@roeck-us.net> wrote:
>>>
>>> On 6/23/23 10:44, Peter Maydell wrote:
>>>> On Sat, 17 Jun 2023 at 17:29, Guenter Roeck <linux@roeck-us.net> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> On Tue, May 23, 2023 at 06:04:58PM +0800, qianfanguijin@163.com wrote:
>>>>>> From: qianfan Zhao <qianfanguijin@163.com>
>>>>>>
>>>>>> Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU,
>>>>>> and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3
>>>>>> for In-Car Entertainment usage, A40i and A40pro are variants that
>>>>>> differ in applicable temperatures range (industrial and military).
>>>>>>
>>>>>> Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
>>>>>> Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
>>>>>
>>>>> I tried this in mainline linux with the following command.
>>>>>
>>>>> qemu-system-arm -M bpim2u \
>>>>>           -kernel arch/arm/boot/zImage -no-reboot \
>>>>>           -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \
>>>>>           -nic user \
>>>>>           --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \
>>>>>           -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \
>>>>>           -nographic -monitor null -serial stdio
>>>>>
>>>>> Main problem is that the SD card gets instantiated randomly to
>>>>> mmc0, mmc1, or mmc2, making it all but impossible to specify a
>>>>> root file system device. The non-instantiated cards are always
>>>>> reported as non-removable, including mmc0. Example:
>>>>>
>>>>> mmc0: Failed to initialize a non-removable card
>>>>
>>>> Do you mean that QEMU randomly connects the SD card to
>>>> a different MMC controller each time, or that Linux is
>>>> randomly assigning mmc0 to a different MMC controller each
>>>> time ?
>>>>
>>>
>>> Good question. Given the workaround (fix ?) I suggested is
>>> in the devicetree file, I would assume it is the latter. I suspect
>>> that Linux assigns drive names based on hardware detection order,
>>> and that this is not deterministic for some reason. It is odd
>>> because I have never experienced that with any other emulation.
>>
>> Yeah, I don't really understand why it would be non-deterministic.
>> But it does make it sound like the right thing is for the
>> device tree file to explicitly say which MMC controller is
>> which -- presumably you might get unlucky with the timing
>> on real hardware too.
>>
> 
> Agreed, only someone with real hardware would have to confirm
> that this is the case.
> 

Actually, the reason is quite simple. In the Linux kernel:

static struct platform_driver sunxi_mmc_driver = {
         .driver = {
                 .name   = "sunxi-mmc",
                 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
                               ^^^^^^^^^^^^^^^^^^^^^^^^^
                 .of_match_table = sunxi_mmc_of_match,
                 .pm = &sunxi_mmc_pm_ops,
         },
         .probe          = sunxi_mmc_probe,
         .remove         = sunxi_mmc_remove,
};

All mmc devices instantiate at the same time, thus the
device name association is random. If I drop the probe_type
assignment, it becomes deterministic.

On top of that, Linux does know which drives are removable
from the devicetree file. However, since probe order is
random, the assignment of the one removable drive to device
names is random. Sometimes mmc0 shows up as removable,
sometimes it is mmc1 or mmc2.

So my conclusion is that qemu isn't doing anything wrong,
it is all happening in the Linux kernel.

Thanks, and sorry for the noise.

Guenter



  reply	other threads:[~2023-06-24 15:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 10:04 [PATCH v5 00/11] *** Add allwinner-r40 support *** qianfanguijin
2023-05-23 10:04 ` [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support qianfanguijin
2023-06-17 16:29   ` Guenter Roeck
2023-06-18  0:40     ` qianfan
2023-06-23 17:36       ` Guenter Roeck
2023-06-23 17:44     ` Peter Maydell
2023-06-23 19:33       ` Guenter Roeck
2023-06-24 10:40         ` Peter Maydell
2023-06-24 14:23           ` Guenter Roeck
2023-06-24 15:02             ` Guenter Roeck [this message]
2023-08-01 16:01               ` Peter Maydell
2023-08-01 17:03                 ` Guenter Roeck
2023-05-23 10:04 ` [PATCH v5 02/11] hw/arm/allwinner-r40: add Clock Control Unit qianfanguijin
2023-05-23 10:05 ` [PATCH v5 03/11] hw: allwinner-r40: Complete uart devices qianfanguijin
2023-05-23 10:05 ` [PATCH v5 04/11] hw: arm: allwinner-r40: Add i2c0 device qianfanguijin
2023-05-23 10:05 ` [PATCH v5 05/11] hw/misc: Rename axp209 to axp22x and add support AXP221 PMU qianfanguijin
2023-05-23 10:05 ` [PATCH v5 06/11] hw/arm/allwinner-r40: add SDRAM controller device qianfanguijin
2023-05-23 10:05 ` [PATCH v5 07/11] hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support qianfanguijin
2023-05-23 10:05 ` [PATCH v5 08/11] hw: arm: allwinner-r40: Add emac and gmac support qianfanguijin
2023-05-23 10:05 ` [PATCH v5 09/11] hw: arm: allwinner-sramc: Add SRAM Controller support for R40 qianfanguijin
2023-05-23 10:05 ` [PATCH v5 10/11] tests: avocado: boot_linux_console: Add test case for bpim2u qianfanguijin
2023-06-01 18:47 ` [PATCH v5 00/11] *** Add allwinner-r40 support *** Niek Linnenbank
2023-06-05 15:30   ` Peter Maydell
2023-06-07 19:06     ` Niek Linnenbank

Reply instructions:

You may reply publicly 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=01087628-44c0-2b15-61bc-8677b7d1b459@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=b.galvani@gmail.com \
    --cc=nieklinnenbank@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qianfanguijin@163.com \
    --cc=strahinja.p.jankovic@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).