qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Kevin O'Connor <kevin@koconnor.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] sdhci: Pass drive parameter to sdhci-pci via qdev property
Date: Wed, 29 Jul 2015 10:01:03 +0100	[thread overview]
Message-ID: <20150729090103.GC10617@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1438100563-14453-1-git-send-email-kevin@koconnor.net>

[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]

On Tue, Jul 28, 2015 at 12:22:43PM -0400, Kevin O'Connor wrote:
> Commit 19109131 disabled the sdhci-pci support because it used
> drive_get_next().  This patch reenables sdhci-pci and changes it to
> pass the drive via a qdev property - for example:
>  -device sdhci-pci,drive=drive0 -drive id=drive0,if=sd,file=myimage
> 
> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
> ---
> 
> This patch only changes the SDHCI PCI code - the sysbus code continues
> to use drive_get_next().
> 
> The call to blk_detach_dev() is suspicious - I added it because
> sd.c:sd_init() calls blk_attach_dev_nofail() and that causes a crash
> if the drive is already attached to the PCI device.  It's not clear to
> me how this should be wired up though.

Ugly bits:

hw/core/qdev-properties-system.c:release_drive() will call
blk_detach_dev(*ptr, dev) and assert(blk->dev == dev) will fail.

The SD card (SDState) isn't a DeviceState, it's a plain old C struct.
So it doesn't have the qdev machinery for its own drive property.

There is no detach call paired with sd_init() attach, so that's ugly
too.

A solution:

Add an sd_init() flag argument that skips the attach/set_dev_ops calls.
Make sd_cardchange() externally visible and then call blk_set_dev_ops()
from sdhci.c instead.

That way, existing users can rely on the semi-broken but convenient
sd_init() behavior.  sdhci can forward the .change_media_cb() to
sd_cardchange() keep itself as the blk->dev pointer.

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-07-29  9:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 16:22 [Qemu-devel] [PATCH] sdhci: Pass drive parameter to sdhci-pci via qdev property Kevin O'Connor
2015-07-29  9:01 ` Stefan Hajnoczi [this message]
2015-07-30 18:04   ` Kevin O'Connor
2015-07-31  8:29     ` Stefan Hajnoczi

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=20150729090103.GC10617@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=armbru@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=pbonzini@redhat.com \
    --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).