qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: pbonzini@redhat.com, hare@suse.de, qemu-block@nongnu.org,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] ahci: fix signature generation
Date: Tue, 7 Jul 2015 09:49:29 +0100	[thread overview]
Message-ID: <20150707084929.GB25892@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1436219392-31915-3-git-send-email-jsnow@redhat.com>

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

On Mon, Jul 06, 2015 at 05:49:52PM -0400, John Snow wrote:
> The initial register device-to-host FIS no longer needs to specially
> set certain fields, as these can be handled generically by setting those
> fields explicitly with the signatures we want at port reset time.
> 
> (1) Signatures are decomposed into their four component registers and
>     set upon (AHCI) port reset.
> (2) the signature cache register is no longer set manually per-each
>     device type, but instead just once during ahci_init_d2h.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  hw/ide/ahci.c | 33 ++++++++++++++++++++-------------
>  1 file changed, 20 insertions(+), 13 deletions(-)

I see two code paths that call ahci_init_d2h().  Either
ahci_reset_port() does it (if a block device is attached) or it's called
when the guest writes to the PORT_CMD register.

I'm not sure the latter works.  The signature doesn't seem to be set
anywhere.

Any ideas?

> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> index bb6a92f..f352dd7 100644
> --- a/hw/ide/ahci.c
> +++ b/hw/ide/ahci.c
> @@ -537,20 +537,31 @@ static void ahci_init_d2h(AHCIDevice *ad)
>  {
>      uint8_t init_fis[20];
>      IDEState *ide_state = &ad->port.ifs[0];
> +    AHCIPortRegs *pr = &ad->port_regs;
>  
>      memset(init_fis, 0, sizeof(init_fis));
>  
> -    init_fis[4] = 1;
> -    init_fis[12] = 1;
> -
> -    if (ide_state->drive_kind == IDE_CD) {
> -        init_fis[5] = ide_state->lcyl;
> -        init_fis[6] = ide_state->hcyl;
> -    }
> +    /* We're emulating receiving the first Reg H2D Fis from the device;
> +     * Update the SIG register, but otherwise procede as normal. */
> +    pr->sig = (ide_state->hcyl << 24) |
> +        (ide_state->lcyl << 16) |
> +        (ide_state->sector << 8) |
> +        (ide_state->nsector & 0xFF);
>  
>      ahci_write_fis_d2h(ad, init_fis);
>  }
>  
> +static void ahci_set_signature(AHCIDevice *ad, uint32_t sig)
> +{
> +    IDEState *s = &ad->port.ifs[0];
> +    s->hcyl = sig >> 24 & 0xFF;
> +    s->lcyl = sig >> 16 & 0xFF;
> +    s->sector = sig >> 8 & 0xFF;
> +    s->nsector = sig & 0xFF;
> +
> +    DPRINTF(ad->port_no, "set hcyl:lcyl:sect:nsect = 0x%08x\n", sig);
> +}
> +
>  static void ahci_reset_port(AHCIState *s, int port)
>  {
>      AHCIDevice *d = &s->dev[port];
> @@ -600,16 +611,12 @@ static void ahci_reset_port(AHCIState *s, int port)
>  
>      s->dev[port].port_state = STATE_RUN;
>      if (!ide_state->blk) {
> -        pr->sig = 0;
>          ide_state->status = SEEK_STAT | WRERR_STAT;
>      } else if (ide_state->drive_kind == IDE_CD) {
> -        pr->sig = SATA_SIGNATURE_CDROM;
> -        ide_state->lcyl = 0x14;
> -        ide_state->hcyl = 0xeb;
> -        DPRINTF(port, "set lcyl = %d\n", ide_state->lcyl);
> +        ahci_set_signature(d, SATA_SIGNATURE_CDROM);
>          ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT;
>      } else {
> -        pr->sig = SATA_SIGNATURE_DISK;
> +        ahci_set_signature(d, SATA_SIGNATURE_DISK);
>          ide_state->status = SEEK_STAT | WRERR_STAT;
>      }
>  
> -- 
> 2.1.0
> 

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

  reply	other threads:[~2015-07-07  8:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 21:49 [Qemu-devel] [PATCH 0/2] ahci: Fix CD-ROM signature John Snow
2015-07-06 21:49 ` [Qemu-devel] [PATCH 1/2] " John Snow
2015-07-07 17:19   ` John Snow
2015-07-08  9:26     ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2015-07-06 21:49 ` [Qemu-devel] [PATCH 2/2] ahci: fix signature generation John Snow
2015-07-07  8:49   ` Stefan Hajnoczi [this message]
2015-07-07 17:15     ` John Snow
2015-07-08 12:56       ` Stefan Hajnoczi
2015-07-08 15:18         ` John Snow

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=20150707084929.GB25892@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=hare@suse.de \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.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).