* [Qemu-devel] cmdline: How to connect a SD card to a specific SD controller?
@ 2018-05-28 4:30 Philippe Mathieu-Daudé
2018-05-29 23:08 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-05-28 4:30 UTC (permalink / raw)
To: Peter Maydell, Thomas Huth, Igor Mitsyanko, Kevin Wolf, Max Reitz,
Paolo Bonzini, Marcel Apfelbaum
Cc: qemu-devel@nongnu.org, open list:Block layer core,
Michael S. Tsirkin, Alistair Francis, Sai Pavan Boddu
[-- Attachment #1: Type: text/plain, Size: 6347 bytes --]
Hi,
I'd like to connect a specific SD card to a specific SDHCI from command
line, and I'm getting a bit lost with command line options.
I'm using an updated version of this patch, but this is not relevant to
this thread:
http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg01914.html
In the following example, I'd like to connect an UHS-I enabled SD card
to the first SHDCI of the Exynos4210 board (Nuri).
I tried:
$ ./arm-softmmu/qemu-system-arm -M nuri \
-device sd-card,id=sd0,uhs=1 \
-drive if=sd,id=sd0,driver=null-co,size=4G \
-monitor stdio -S
But then the QTree looks unexpected:
(qemu) info qtree
bus: main-system-bus
type System
dev: generic-sdhci, id ""
gpio-out "sysbus-irq" 1
sd-spec-version = 2 (0x2)
uhs = 0 (0x0)
capareg = 99090560 (0x5e80080)
maxcurr = 0 (0x0)
pending-insert-quirk = false
dma = ""
mmio 0000000012540000/0000000000000100
bus: sd-bus
type sdhci-bus
dev: sd-card, id "sd0"
drive = ""
spi = false
uhs = 1 (0x1)
dev: sd-card, id ""
drive = ""
spi = false
uhs = 0 (0x0)
^---- 2 cards
dev: generic-sdhci, id ""
gpio-out "sysbus-irq" 1
sd-spec-version = 2 (0x2)
uhs = 0 (0x0)
capareg = 99090560 (0x5e80080)
maxcurr = 0 (0x0)
pending-insert-quirk = false
dma = ""
mmio 0000000012530000/0000000000000100
bus: sd-bus
type sdhci-bus
dev: sd-card, id ""
drive = ""
spi = false
uhs = 0 (0x0)
dev: generic-sdhci, id ""
gpio-out "sysbus-irq" 1
sd-spec-version = 2 (0x2)
uhs = 0 (0x0)
capareg = 99090560 (0x5e80080)
maxcurr = 0 (0x0)
pending-insert-quirk = false
dma = ""
mmio 0000000012520000/0000000000000100
bus: sd-bus
type sdhci-bus
dev: sd-card, id ""
drive = ""
spi = false
uhs = 0 (0x0)
dev: generic-sdhci, id ""
gpio-out "sysbus-irq" 1
sd-spec-version = 2 (0x2)
uhs = 0 (0x0)
capareg = 99090560 (0x5e80080)
maxcurr = 0 (0x0)
pending-insert-quirk = false
dma = ""
mmio 0000000012510000/0000000000000100
bus: sd-bus
type sdhci-bus
dev: sd-card, id ""
drive = "sd0"
^------- drive is here
spi = false
uhs = 0 (0x0)
in hw/sd/core.c we have:
static SDState *get_card(SDBus *sdbus)
{
/* We only ever have one child on the bus so just return it */
BusChild *kid = QTAILQ_FIRST(&sdbus->qbus.children);
if (!kid) {
return NULL;
}
return SD_CARD(kid->child);
}
Spec v1 allow multiple cards per bus but Spec v2 (and up) restrict to 1
per bus.
in exynos4210_init() we have:
di = drive_get(IF_SD, 0, n);
blk = di ? blk_by_legacy_dinfo(di) : NULL;
carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"),
TYPE_SD_CARD);
so there are no restriction in connecting various slaves to the same bus.
I also wonder about this drive_get(), is this an outdated API?
Only used in 3 boards:
$ git grep 'drive_get(IF_SD'
hw/arm/exynos4210.c:397: di = drive_get(IF_SD, 0, n);
hw/arm/omap1.c:3990: dinfo = drive_get(IF_SD, 0, 0);
hw/arm/omap2.c:2489: dinfo = drive_get(IF_SD, 0, 0);
hw/arm/pxa2xx.c:2098: dinfo = drive_get(IF_SD, 0, 0);
hw/arm/pxa2xx.c:2222: dinfo = drive_get(IF_SD, 0, 0);
versus drive_get_next() used in others:
hw/arm/mcimx7d-sabre.c:70: di = drive_get_next(IF_SD);
hw/arm/raspi.c:200: di = drive_get_next(IF_SD);
hw/arm/xilinx_zynq.c:269: di = drive_get_next(IF_SD);
hw/arm/xlnx-zcu102.c:114: DriveInfo *di = drive_get_next(IF_SD);
hw/sd/milkymist-memcard.c:279: dinfo = drive_get_next(IF_SD);
hw/sd/pl181.c:508: dinfo = drive_get_next(IF_SD);
hw/sd/ssi-sd.c:254: dinfo = drive_get_next(IF_SD);
Now trying with the PC machine:
$ x86_64-softmmu/qemu-system-x86_64 -M pc \
-device sdhci-pci,id=sdhci1 \
-device sdhci-pci,id=sdhci2,sd-spec-version=3,uhs=2 \
-device sd-card,id=sdcard0 \
-device sd-card,uhs=1,id=sdcard1 \
-monitor stdio -S
(qemu) info qtree
bus: main-system-bus
type System
dev: i440FX-pcihost, id ""
bus: pci.0
type PCI
dev: sdhci-pci, id "sdhci2"
sd-spec-version = 3 (0x3)
uhs = 2 (0x2)
capareg = 91763892 (0x57834b4)
maxcurr = 0 (0x0)
addr = 05.0
romfile = ""
rombar = 1 (0x1)
multifunction = false
command_serr_enable = true
x-pcie-lnksta-dllla = true
x-pcie-extcap-init = true
class Class 0805, addr 00:05.0, pci id 1b36:0007 (sub 1af4:1100)
bar 0: mem at 0xffffffffffffffff [0xfe]
bus: sd-bus
type sdhci-bus
dev: sd-card, id "sdcard1"
drive = ""
spi = false
uhs = 1 (0x1)
dev: sd-card, id "sdcard0"
drive = ""
spi = false
uhs = 0 (0x0)
^--- 2 cards...
dev: sdhci-pci, id "sdhci1"
sd-spec-version = 2 (0x2)
uhs = 0 (0x0)
capareg = 91763892 (0x57834b4)
maxcurr = 0 (0x0)
addr = 04.0
romfile = ""
rombar = 1 (0x1)
multifunction = false
command_serr_enable = true
x-pcie-lnksta-dllla = true
x-pcie-extcap-init = true
class Class 0805, addr 00:04.0, pci id 1b36:0007 (sub 1af4:1100)
bar 0: mem at 0xffffffffffffffff [0xfe]
bus: sd-bus
type sdhci-bus
^--- no card
And trying the -drive option:
$ x86_64-softmmu/qemu-system-x86_64 -M pc \
-device sdhci-pci,id=sdhci1 \
-device sdhci-pci,id=sdhci2,sd-spec-version=3,uhs=2 \
-device sd-card,id=sdcard0 \
-device sd-card,uhs=1,id=sdcard1 \
-drive if=sd,id=sd0,driver=null-co,size=2G \
-drive if=sd,id=sd1,driver=null-co,size=4G
qemu-system-x86_64: -drive if=sd,id=sd0,driver=null-co,size=2G: machine
type does not support if=sd,bus=0,unit=0
qemu-system-x86_64: -drive if=sd,id=sd1,driver=null-co,size=4G: machine
type does not support if=sd,bus=0,unit=1
How can I create the card with UHS-I enabled and connect it to the 2nd
SDHCI?
Thanks!
Phil.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] cmdline: How to connect a SD card to a specific SD controller?
2018-05-28 4:30 [Qemu-devel] cmdline: How to connect a SD card to a specific SD controller? Philippe Mathieu-Daudé
@ 2018-05-29 23:08 ` Philippe Mathieu-Daudé
2018-05-30 5:28 ` Thomas Huth
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-05-29 23:08 UTC (permalink / raw)
To: Thomas Huth, Igor Mitsyanko, Kevin Wolf, Max Reitz, Paolo Bonzini,
Marcel Apfelbaum
Cc: Peter Maydell, qemu-devel@nongnu.org, open list:Block layer core,
Michael S. Tsirkin, Alistair Francis, Sai Pavan Boddu
[-- Attachment #1: Type: text/plain, Size: 7798 bytes --]
On 05/28/2018 01:30 AM, Philippe Mathieu-Daudé wrote:
> Hi,
>
> I'd like to connect a specific SD card to a specific SDHCI from command
> line, and I'm getting a bit lost with command line options.
>
> I'm using an updated version of this patch, but this is not relevant to
> this thread:
> http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg01914.html
>
> In the following example, I'd like to connect an UHS-I enabled SD card
> to the first SHDCI of the Exynos4210 board (Nuri).
>
> I tried:
>
> $ ./arm-softmmu/qemu-system-arm -M nuri \
> -device sd-card,id=sd0,uhs=1 \
> -drive if=sd,id=sd0,driver=null-co,size=4G \
> -monitor stdio -S
Peter suggested on IRC to use:
-drive if=none,id=mydrive,... -device sd-card,...,drive=mydrive
which indeed works enough for my tests:
$ ./arm-softmmu/qemu-system-arm -M nuri \
-drive if=none,id=mydrive,driver=null-co,size=4G \
-device sd-card,id=sd0,uhs=1,drive=mydrive \
-monitor stdio -S
The same issues are still here but don't bother:
(qemu) info qtree
bus: main-system-bus
type System
dev: generic-sdhci, id ""
gpio-out "sysbus-irq" 1
sd-spec-version = 2 (0x2)
uhs = 0 (0x0)
capareg = 99090560 (0x5e80080)
maxcurr = 0 (0x0)
pending-insert-quirk = false
dma = ""
mmio 0000000012540000/0000000000000100
bus: sd-bus
type sdhci-bus
dev: sd-card, id "sd0"
drive = "mydrive"
spi = false
uhs = 1 (0x1)
dev: sd-card, id ""
drive = ""
spi = false
uhs = 0 (0x0)
^---- 2 cards
> But then the QTree looks unexpected:
>
> (qemu) info qtree
> bus: main-system-bus
> type System
> dev: generic-sdhci, id ""
> gpio-out "sysbus-irq" 1
> sd-spec-version = 2 (0x2)
> uhs = 0 (0x0)
> capareg = 99090560 (0x5e80080)
> maxcurr = 0 (0x0)
> pending-insert-quirk = false
> dma = ""
> mmio 0000000012540000/0000000000000100
> bus: sd-bus
> type sdhci-bus
> dev: sd-card, id "sd0"
> drive = ""
> spi = false
> uhs = 1 (0x1)
> dev: sd-card, id ""
> drive = ""
> spi = false
> uhs = 0 (0x0)
>
> ^---- 2 cards
>
> dev: generic-sdhci, id ""
> gpio-out "sysbus-irq" 1
> sd-spec-version = 2 (0x2)
> uhs = 0 (0x0)
> capareg = 99090560 (0x5e80080)
> maxcurr = 0 (0x0)
> pending-insert-quirk = false
> dma = ""
> mmio 0000000012530000/0000000000000100
> bus: sd-bus
> type sdhci-bus
> dev: sd-card, id ""
> drive = ""
> spi = false
> uhs = 0 (0x0)
> dev: generic-sdhci, id ""
> gpio-out "sysbus-irq" 1
> sd-spec-version = 2 (0x2)
> uhs = 0 (0x0)
> capareg = 99090560 (0x5e80080)
> maxcurr = 0 (0x0)
> pending-insert-quirk = false
> dma = ""
> mmio 0000000012520000/0000000000000100
> bus: sd-bus
> type sdhci-bus
> dev: sd-card, id ""
> drive = ""
> spi = false
> uhs = 0 (0x0)
> dev: generic-sdhci, id ""
> gpio-out "sysbus-irq" 1
> sd-spec-version = 2 (0x2)
> uhs = 0 (0x0)
> capareg = 99090560 (0x5e80080)
> maxcurr = 0 (0x0)
> pending-insert-quirk = false
> dma = ""
> mmio 0000000012510000/0000000000000100
> bus: sd-bus
> type sdhci-bus
> dev: sd-card, id ""
> drive = "sd0"
>
> ^------- drive is here
>
> spi = false
> uhs = 0 (0x0)
>
> in hw/sd/core.c we have:
>
> static SDState *get_card(SDBus *sdbus)
> {
> /* We only ever have one child on the bus so just return it */
> BusChild *kid = QTAILQ_FIRST(&sdbus->qbus.children);
>
> if (!kid) {
> return NULL;
> }
> return SD_CARD(kid->child);
> }
>
> Spec v1 allow multiple cards per bus but Spec v2 (and up) restrict to 1
> per bus.
>
>
> in exynos4210_init() we have:
>
> di = drive_get(IF_SD, 0, n);
> blk = di ? blk_by_legacy_dinfo(di) : NULL;
> carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"),
> TYPE_SD_CARD);
>
> so there are no restriction in connecting various slaves to the same bus.
>
> I also wonder about this drive_get(), is this an outdated API?
>
> Only used in 3 boards:
>
> $ git grep 'drive_get(IF_SD'
> hw/arm/exynos4210.c:397: di = drive_get(IF_SD, 0, n);
> hw/arm/omap1.c:3990: dinfo = drive_get(IF_SD, 0, 0);
> hw/arm/omap2.c:2489: dinfo = drive_get(IF_SD, 0, 0);
> hw/arm/pxa2xx.c:2098: dinfo = drive_get(IF_SD, 0, 0);
> hw/arm/pxa2xx.c:2222: dinfo = drive_get(IF_SD, 0, 0);
>
> versus drive_get_next() used in others:
>
> hw/arm/mcimx7d-sabre.c:70: di = drive_get_next(IF_SD);
> hw/arm/raspi.c:200: di = drive_get_next(IF_SD);
> hw/arm/xilinx_zynq.c:269: di = drive_get_next(IF_SD);
> hw/arm/xlnx-zcu102.c:114: DriveInfo *di = drive_get_next(IF_SD);
> hw/sd/milkymist-memcard.c:279: dinfo = drive_get_next(IF_SD);
> hw/sd/pl181.c:508: dinfo = drive_get_next(IF_SD);
> hw/sd/ssi-sd.c:254: dinfo = drive_get_next(IF_SD);
>
> Now trying with the PC machine:
>
> $ x86_64-softmmu/qemu-system-x86_64 -M pc \
> -device sdhci-pci,id=sdhci1 \
> -device sdhci-pci,id=sdhci2,sd-spec-version=3,uhs=2 \
> -device sd-card,id=sdcard0 \
> -device sd-card,uhs=1,id=sdcard1 \
> -monitor stdio -S
>
> (qemu) info qtree
> bus: main-system-bus
> type System
> dev: i440FX-pcihost, id ""
> bus: pci.0
> type PCI
> dev: sdhci-pci, id "sdhci2"
> sd-spec-version = 3 (0x3)
> uhs = 2 (0x2)
> capareg = 91763892 (0x57834b4)
> maxcurr = 0 (0x0)
> addr = 05.0
> romfile = ""
> rombar = 1 (0x1)
> multifunction = false
> command_serr_enable = true
> x-pcie-lnksta-dllla = true
> x-pcie-extcap-init = true
> class Class 0805, addr 00:05.0, pci id 1b36:0007 (sub 1af4:1100)
> bar 0: mem at 0xffffffffffffffff [0xfe]
> bus: sd-bus
> type sdhci-bus
> dev: sd-card, id "sdcard1"
> drive = ""
> spi = false
> uhs = 1 (0x1)
> dev: sd-card, id "sdcard0"
> drive = ""
> spi = false
> uhs = 0 (0x0)
>
> ^--- 2 cards...
>
> dev: sdhci-pci, id "sdhci1"
> sd-spec-version = 2 (0x2)
> uhs = 0 (0x0)
> capareg = 91763892 (0x57834b4)
> maxcurr = 0 (0x0)
> addr = 04.0
> romfile = ""
> rombar = 1 (0x1)
> multifunction = false
> command_serr_enable = true
> x-pcie-lnksta-dllla = true
> x-pcie-extcap-init = true
> class Class 0805, addr 00:04.0, pci id 1b36:0007 (sub 1af4:1100)
> bar 0: mem at 0xffffffffffffffff [0xfe]
> bus: sd-bus
> type sdhci-bus
>
> ^--- no card
>
> And trying the -drive option:
>
> $ x86_64-softmmu/qemu-system-x86_64 -M pc \
> -device sdhci-pci,id=sdhci1 \
> -device sdhci-pci,id=sdhci2,sd-spec-version=3,uhs=2 \
> -device sd-card,id=sdcard0 \
> -device sd-card,uhs=1,id=sdcard1 \
> -drive if=sd,id=sd0,driver=null-co,size=2G \
> -drive if=sd,id=sd1,driver=null-co,size=4G
> qemu-system-x86_64: -drive if=sd,id=sd0,driver=null-co,size=2G: machine
> type does not support if=sd,bus=0,unit=0
> qemu-system-x86_64: -drive if=sd,id=sd1,driver=null-co,size=4G: machine
> type does not support if=sd,bus=0,unit=1
>
> How can I create the card with UHS-I enabled and connect it to the 2nd
> SDHCI?
>
> Thanks!
>
> Phil.
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] cmdline: How to connect a SD card to a specific SD controller?
2018-05-29 23:08 ` Philippe Mathieu-Daudé
@ 2018-05-30 5:28 ` Thomas Huth
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2018-05-30 5:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Igor Mitsyanko, Kevin Wolf,
Max Reitz, Paolo Bonzini, Marcel Apfelbaum
Cc: Peter Maydell, qemu-devel@nongnu.org, open list:Block layer core,
Michael S. Tsirkin, Alistair Francis, Sai Pavan Boddu
[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]
On 30.05.2018 01:08, Philippe Mathieu-Daudé wrote:
> On 05/28/2018 01:30 AM, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> I'd like to connect a specific SD card to a specific SDHCI from command
>> line, and I'm getting a bit lost with command line options.
>>
>> I'm using an updated version of this patch, but this is not relevant to
>> this thread:
>> http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg01914.html
>>
>> In the following example, I'd like to connect an UHS-I enabled SD card
>> to the first SHDCI of the Exynos4210 board (Nuri).
>>
>> I tried:
>>
>> $ ./arm-softmmu/qemu-system-arm -M nuri \
>> -device sd-card,id=sd0,uhs=1 \
>> -drive if=sd,id=sd0,driver=null-co,size=4G \
>> -monitor stdio -S
>
> Peter suggested on IRC to use:
>
> -drive if=none,id=mydrive,... -device sd-card,...,drive=mydrive
>
> which indeed works enough for my tests:
>
> $ ./arm-softmmu/qemu-system-arm -M nuri \
> -drive if=none,id=mydrive,driver=null-co,size=4G \
> -device sd-card,id=sd0,uhs=1,drive=mydrive \
> -monitor stdio -S
>
> The same issues are still here but don't bother:
>
> (qemu) info qtree
> bus: main-system-bus
> type System
> dev: generic-sdhci, id ""
> gpio-out "sysbus-irq" 1
> sd-spec-version = 2 (0x2)
> uhs = 0 (0x0)
> capareg = 99090560 (0x5e80080)
> maxcurr = 0 (0x0)
> pending-insert-quirk = false
> dma = ""
> mmio 0000000012540000/0000000000000100
> bus: sd-bus
> type sdhci-bus
> dev: sd-card, id "sd0"
> drive = "mydrive"
> spi = false
> uhs = 1 (0x1)
> dev: sd-card, id ""
> drive = ""
> spi = false
> uhs = 0 (0x0)
>
> ^---- 2 cards
Looks like the nuri board always creates an sd-card by default? You
could try to change exynos4210_init() to only create it if
drive_get(IF_SD, ...) is not returning NULL - then it should be possible
to disable it with "-nodefaults".
Thomas
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-30 5:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 4:30 [Qemu-devel] cmdline: How to connect a SD card to a specific SD controller? Philippe Mathieu-Daudé
2018-05-29 23:08 ` Philippe Mathieu-Daudé
2018-05-30 5:28 ` Thomas Huth
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).