-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1
 
 iQIcBAABAgAGBQJWVhkxAAoJEH3vgQaq/DkOx3kP/1ltX2d+EEaCTNFhaDD+RqDd
 elfkfh04gtP+8S7zcfSibe7NnbmQBYrwDZa0XfE+mDG5zNPx+e6Y3CHaRdmQ4cqS
 1mPCRBmSvSS2/tHs9QtYS6H8Qlv4BkOpuzykoKbkMdABb0w8w1IGqiH4oRghjUrn
 NTOfWoGqLStwUGj/jur2x7lXz6x5grQLflykuoWWcX7UuPp5U47UMHNUohfwvIJ3
 gN4/KaloNcxbbFMjh/CEM4fSjDdlP45eSAeRFu50x5G0pzqrnrMO/iHYC3AjXujB
 2j8f72guP3L/fdoqcQbwVyXqDNukU3aFizggNG73ob8r5SemOMj0Q85Nl5zbtsDI
 5Iq4B6y4KAh7uTH+9h9IlCi+MWo62WdHV5lNcBKw25K1SFDx37LWQT9YInlLKSkb
 xAfzOMvH2nNi8OMbwVCizQQ3XCzf3c2JJSOC0ONkdgbWB5GRk6uvuykkzXGfIYxo
 9Q8XVdHB2KN9UYBC4lcmprj28QF39UImuibL1OHaVt3jTSEjjsSUNbwEEgFrfFfg
 tCJWBI/iNFNJ/Eg6hHPSqMdqoenNJAmg+KxG26WNvmnevV0Z/182K3qrfvXFrbhb
 z39KU+ImjiWxKyk8DvvKE6VdOdiI6FsPAnjhuR5AkKcPCNwz7s+NrhZ5ahaeo2xJ
 dJDs+aE5culxKiuotb2w
 =Wvdc
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging

# gpg: Signature made Wed 25 Nov 2015 20:25:21 GMT using RSA key ID AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"

* remotes/jnsnow/tags/ide-pull-request:
  ide-test: fix timeouts
  atapi: Fix code indentation
  atapi: Account for failed and invalid operations in cd_read_sector()
  ide-test: cdrom_pio_impl fixup

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-11-26 09:44:25 +00:00
commit 7ef7ddf376
2 changed files with 28 additions and 12 deletions

View File

@ -148,17 +148,18 @@ static void cd_read_sector_cb(void *opaque, int ret)
{
IDEState *s = opaque;
block_acct_done(blk_get_stats(s->blk), &s->acct);
#ifdef DEBUG_IDE_ATAPI
printf("cd_read_sector_cb: lba=%d ret=%d\n", s->lba, ret);
#endif
if (ret < 0) {
block_acct_failed(blk_get_stats(s->blk), &s->acct);
ide_atapi_io_error(s, ret);
return;
}
block_acct_done(blk_get_stats(s->blk), &s->acct);
if (s->cd_sector_size == 2352) {
cd_data_to_raw(s->io_buffer, s->lba);
}
@ -173,6 +174,7 @@ static void cd_read_sector_cb(void *opaque, int ret)
static int cd_read_sector(IDEState *s)
{
if (s->cd_sector_size != 2048 && s->cd_sector_size != 2352) {
block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_READ);
return -EINVAL;
}
@ -441,7 +443,7 @@ eot:
if (ret < 0) {
block_acct_failed(blk_get_stats(s->blk), &s->acct);
} else {
block_acct_done(blk_get_stats(s->blk), &s->acct);
block_acct_done(blk_get_stats(s->blk), &s->acct);
}
ide_set_inactive(s, false);
}

View File

@ -642,15 +642,19 @@ static void nsleep(int64_t nsecs)
static uint8_t ide_wait_clear(uint8_t flag)
{
int i;
uint8_t data;
time_t st;
/* Wait with a 5 second timeout */
for (i = 0; i <= 12500000; i++) {
time(&st);
while (true) {
data = inb(IDE_BASE + reg_status);
if (!(data & flag)) {
return data;
}
if (difftime(time(NULL), st) > 5.0) {
break;
}
nsleep(400);
}
g_assert_not_reached();
@ -658,14 +662,18 @@ static uint8_t ide_wait_clear(uint8_t flag)
static void ide_wait_intr(int irq)
{
int i;
time_t st;
bool intr;
for (i = 0; i <= 12500000; i++) {
time(&st);
while (true) {
intr = get_irq(irq);
if (intr) {
return;
}
if (difftime(time(NULL), st) > 5.0) {
break;
}
nsleep(400);
}
@ -709,9 +717,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 +728,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);