Received: from eggs.gnu.org ([208.118.235.92]:59460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Strhq-0001nQ-Gs for qemu-devel@nongnu.org; Tue, 24 Jul 2012 22:52:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Strhp-0002ni-E4 for qemu-devel@nongnu.org; Tue, 24 Jul 2012 22:52:10 -0400 Received: from gate.crashing.org ([63.228.1.57]:43614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Strhp-0002na-58 for qemu-devel@nongnu.org; Tue, 24 Jul 2012 22:52:09 -0400 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id q6P2q4ST022176 for ; Tue, 24 Jul 2012 21:52:05 -0500 Message-ID: <1343184724.3715.30.camel@pasglop> From: Benjamin Herrenschmidt Date: Wed, 25 Jul 2012 12:52:04 +1000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: [Qemu-devel] Possible bug in cirrus_vga.c vs. HDR handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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.