qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Possible bug in cirrus_vga.c vs. HDR handling
Date: Wed, 25 Jul 2012 12:52:04 +1000	[thread overview]
Message-ID: <1343184724.3715.30.camel@pasglop> (raw)

Hi folks !

I was debugging a problem with 16bpp support, when I found out that
my attempts at writing to the Hidden DAC Register were not working.

The reason was that I (well, cirrusdrmfb really) was doing the sequence
READ, READ, READ, READ, WRITE (to the DAC mask register), which should
have worked, except that the code in qemu for reads does:

static int cirrus_read_hidden_dac(CirrusVGAState * s)
{
    if (++s->cirrus_hidden_dac_lockindex == 5) {
        s->cirrus_hidden_dac_lockindex = 0;
        return s->cirrus_hidden_dac_data;
    }
    return 0xff;
}

(Note the *pre*increment)

And s->cirrus_hidden_dac_lockindex is initialized in  cirrus_reset() to:

 s->cirrus_hidden_dac_lockindex = 5;

So the first 4 reads cause it to go to 6,7,8,9... and never
actually wrap back, so the write doesn't work as it checks for
the value being exactly 4.

Now, that -might- mimmic the real HW (I've added a workaround to drmfb
that does a dummy write first), but it looks dubious to me.

Shouldn't we initialize the lockindex to 0 in reset ? or to 4 ?

Cheers,
Ben.

                 reply	other threads:[~2012-07-25  2:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1343184724.3715.30.camel@pasglop \
    --to=benh@kernel.crashing.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).