From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1gdS-0002v7-Fh for qemu-devel@nongnu.org; Wed, 25 Nov 2015 15:25:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1gdO-0000VU-EM for qemu-devel@nongnu.org; Wed, 25 Nov 2015 15:25:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1gdO-0000VH-9H for qemu-devel@nongnu.org; Wed, 25 Nov 2015 15:25:46 -0500 From: John Snow Date: Wed, 25 Nov 2015 15:25:39 -0500 Message-Id: <1448483142-32658-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1448483142-32658-1-git-send-email-jsnow@redhat.com> References: <1448483142-32658-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PULL 1/4] ide-test: cdrom_pio_impl fixup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, jsnow@redhat.com Final tidying: move the interrupt wait into the loop, document that the status read clears the IRQ, and move the final interrupt check outside of the loop. This should be functionally equivalent to how it works currently, but a little less ambiguous and slightly more explicit about the state transitions. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-id: 1448060035-31973-3-git-send-email-jsnow@redhat.com --- tests/ide-test.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index fc1ce52..46763db 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -709,9 +709,6 @@ static void cdrom_pio_impl(int nblocks) /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ send_scsi_cdb_read10(0, nblocks); - /* HP3: INTRQ_Wait */ - ide_wait_intr(IDE_PRIMARY_IRQ); - /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes. * We allow an odd limit only when the remaining transfer size is @@ -723,16 +720,25 @@ static void cdrom_pio_impl(int nblocks) for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { size_t offset = i * (limit / 2); size_t rem = (rxsize / 2) - offset; - /* HP2: Check_Status_B */ + + /* HP3: INTRQ_Wait */ + ide_wait_intr(IDE_PRIMARY_IRQ); + + /* HP2: Check_Status_B (and clear IRQ) */ data = ide_wait_clear(BSY); assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); + /* HP4: Transfer_Data */ for (j = 0; j < MIN((limit / 2), rem); j++) { rx[offset + j] = le16_to_cpu(inw(IDE_BASE + reg_data)); } - ide_wait_intr(IDE_PRIMARY_IRQ); } + + /* Check for final completion IRQ */ + ide_wait_intr(IDE_PRIMARY_IRQ); + + /* Sanity check final state */ data = ide_wait_clear(DRQ); assert_bit_set(data, DRDY); assert_bit_clear(data, DRQ | ERR | DF | BSY); -- 2.4.3