From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PATCH for-2.3] sdhci: add "drive" property
Date: Mon, 23 Mar 2015 14:56:12 +0100 [thread overview]
Message-ID: <55101B7C.9040902@redhat.com> (raw)
In-Reply-To: <87wq27n8ed.fsf@blackfin.pond.sub.org>
On 23/03/2015 14:35, Markus Armbruster wrote:
>>> From 30,000ft, this looks a bit like the floppy case: BB's dev points to
>>> the block device, and BB's dev_opaque points within the device.
>>>
>>> If you descend a bit, it looks a lot more like the usb-storage hack that
>>> has caused us nothing but grief: two separate device models attaching to
>>> the same BlockBackend.
>>>
>>> What is the usb-storage hack? Device model usb-storage pretends to be a
>>> block device, but really is a SCSI controller that can serve just one
>>> SCSI device, which it creates automatically, in its realize() method.
>>> Since the automatically created device isn't accessible at -device /
>>> device_add level, we need to stick the drive property for it into
>>> usb-storage. Before the realize() method creates the SCSI device, it
>>> carefully detaches the usb-storage device:
>>>
>>> /*
>>> * Hack alert: this pretends to be a block device, but it's really
>>> * a SCSI bus that can serve only a single device, which it
>>> * creates automatically. But first it needs to detach from its
>>> * blockdev, or else scsi_bus_legacy_add_drive() dies when it
>>> * attaches again.
>>> *
>>> * The hack is probably a bad idea.
>>> */
>>> blk_detach_dev(blk, &s->dev.qdev);
>>> s->conf.blk = NULL;
>>>
>>> Bad idea, but ABI.
>>>
>>> Before we make another bad idea ABI, let's stop and think.
>>>
>>> I believe the proper solution for your problem is qdevifying the SD
>>> card.
>>
>> The question is whether there is a use for qdevifying the SD card.
>
> Okay, that's a fair question.
>
>> Each SD/MMC controller will have exactly zero or one SD cards, but the
>> hw/sd/sd.c interface already treats "BlockBackend ejected" as "zero SD
>> cards":
>>
>> if (!sd->blk || !blk_is_inserted(sd->blk) || !sd->enable) {
>> return 0;
>> }
>>
>> Unlike SCSI, the SD card code:
>>
>> 1) doesn't need multiplexing (a la scsi-hd/scsi-cd/scsi-generic)
>>
>> 2) doesn't have a bus to talk on (real-world SD cards are just connected
>> with GPIO pins; hw/sd/sd.c abstracts the bitbanging protocol but still
>> there is only one device to talk to)
>>
>> So in the end I think it's easier to treat hw/sd/sd.c as the common code
>> for all hw/sd/* devices, like e.g. hw/display/vga.c.
>
> To pick a block device precedent: like floppy.
I picked VGA because you have devices doing fancy stuff on top of the
common code, but floppy and AHCI are similar too.
> I don't like that the floppy controller and its drives are fused.
> However, the fusing has been *much* less grief than the usb-storage
> hack: basically just a weird user interface to configure the drives,
> namely --global instead of --device.
Right, which we don't even have in the case of sdhci-pci.
> If sd.c is common code rather than a device model in its own right,
> perhaps SDState should be unboxed in SDHCIState, just like the FDrive
> are unboxed in FDCtrl. The "drive" property can then be connected
> straight to SDState member blk.
Yes, of course not 2.3 work. Added to BiteSizedTasks.
> Perhaps split sd_init() into two parts: an inner, "common code" part,
> and an outer, "independend non-qdevified device" part.
I think I'm just going to move blk_attach_dev_nofail to the callers, so
that then this patch can just remove the call in sdhci.c.
Paolo
next prev parent reply other threads:[~2015-03-23 13:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-21 15:54 [Qemu-devel] [PATCH for-2.3] sdhci: add "drive" property Paolo Bonzini
2015-03-23 9:10 ` Markus Armbruster
2015-03-23 12:05 ` Paolo Bonzini
2015-03-23 12:09 ` Peter Maydell
2015-03-23 13:19 ` Paolo Bonzini
2015-03-23 13:43 ` Markus Armbruster
2015-03-23 13:35 ` Markus Armbruster
2015-03-23 13:56 ` Paolo Bonzini [this message]
2015-03-23 15:01 ` Peter Crosthwaite
2015-03-23 15:15 ` Peter Maydell
2015-03-23 15:58 ` Paolo Bonzini
2015-03-24 14:53 ` Markus Armbruster
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=55101B7C.9040902@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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
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).