Changeset 2826 in vbox
- Timestamp:
- May 23, 2007 4:08:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r2673 r2826 3388 3388 3389 3389 3390 static voidataIOPortReadU8(PATACONTROLLER pCtl, uint32_t addr, uint32_t *pu32)3390 static int ataIOPortReadU8(PATACONTROLLER pCtl, uint32_t addr, uint32_t *pu32) 3391 3391 { 3392 3392 ATADevState *s = &pCtl->aIfs[pCtl->iSelectedIf]; … … 3455 3455 case 7: /* primary status */ 3456 3456 { 3457 /* Counter for number of busy status seen in GC in a row. */ 3458 static unsigned cBusy = 0; 3459 3457 3460 if (!s->pDrvBlock) 3458 3461 val = 0; 3459 3462 else 3460 3463 val = s->uATARegStatus; 3461 ataUnsetIRQ(s); 3462 #ifdef IN_RING3 3464 3463 3465 /* Give the async I/O thread an opportunity to make progress, 3464 3466 * don't let it starve by guests polling frequently. EMT has a 3465 3467 * lower priority than the async I/O thread, but sometimes the 3466 3468 * host OS doesn't care. With some guests we are only allowed to 3467 * be busy for about 5 milliseconds in some situations. */ 3469 * be busy for about 5 milliseconds in some situations. Note that 3470 * this is no guarantee for any other VBox thread getting 3471 * scheduled, so this just lowers the CPU load a bit when drives 3472 * are busy. It cannot help with timing problems. */ 3468 3473 if (val & ATA_STAT_BUSY) 3469 3474 { 3475 #ifdef IN_RING3 3476 cBusy = 0; 3470 3477 PDMCritSectLeave(&pCtl->lock); 3471 3478 … … 3479 3486 3480 3487 val = s->uATARegStatus; 3488 #else /* !IN_RING3 */ 3489 /* Cannot yield CPU in guest context. And switching to host 3490 * context for each and every busy status is too costly, 3491 * especially on SMP systems where we don't gain much by 3492 * yielding the CPU to someone else. */ 3493 if (++cBusy >= 20) 3494 { 3495 cBusy = 0; 3496 return VINF_IOM_HC_IOPORT_READ; 3497 } 3498 #endif /* !IN_RING3 */ 3481 3499 } 3482 #endif 3500 else 3501 cBusy = 0; 3502 ataUnsetIRQ(s); 3483 3503 break; 3484 3504 } … … 3486 3506 Log2(("%s: addr=%#x val=%#04x\n", __FUNCTION__, addr, val)); 3487 3507 *pu32 = val; 3508 return VINF_SUCCESS; 3488 3509 } 3489 3510 … … 4776 4797 if (cb == 1) 4777 4798 { 4778 ataIOPortReadU8(pCtl, Port, pu32); 4779 rc = VINF_SUCCESS; 4799 rc = ataIOPortReadU8(pCtl, Port, pu32); 4780 4800 } 4781 4801 else if (Port == pCtl->IOPortBase1)
Note:
See TracChangeset
for help on using the changeset viewer.