Changeset 70050 in vbox
- Timestamp:
- Dec 10, 2017 5:28:20 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Devices/USB/DevOHCI.cpp (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DevOHCI.cpp
r69954 r70050 1305 1305 } 1306 1306 1307 static void physReadStatsPrint(P COHCIPHYSREADSTATS p)1307 static void physReadStatsPrint(POHCIPHYSREADSTATS p) 1308 1308 { 1309 1309 p->ed.cMinReadsPerPage = RT_MIN(p->ed.cMinReadsPerPage, p->ed.cReadsLastPage); … … 1401 1401 } 1402 1402 1403 static void ohciR3ReadEdCached(POHCI pThis, uint32_t EdAddr, POHCIED pEd)1404 {1405 ohciR3PhysReadCacheRead(pThis, pThis->pCacheED, EdAddr, pEd, sizeof(*pEd));1406 }1407 1408 static void ohciR3ReadTdCached(POHCI pThis, uint32_t TdAddr, POHCITD pTd)1409 {1410 ohciR3PhysReadCacheRead(pThis, pThis->pCacheTD, TdAddr, pTd, sizeof(*pTd));1411 }1412 1413 1414 1403 /** 1415 1404 * Update any cached ED data with the given endpoint descriptor at the given address. … … 1422 1411 DECLINLINE(void) ohciR3CacheEdUpdate(POHCI pThis, RTGCPHYS32 EdAddr, PCOHCIED pEd) 1423 1412 { 1424 ohciR3PhysCacheUpdate(pThis->pCacheED, EdAddr , pEd, sizeof(*pEd));1413 ohciR3PhysCacheUpdate(pThis->pCacheED, EdAddr + RT_OFFSETOF(OHCIED, HeadP), &pEd->HeadP, sizeof(uint32_t)); 1425 1414 } 1426 1415 … … 1450 1439 physReadStatsUpdateDesc(&g_PhysReadState.all, EdAddr); 1451 1440 # endif 1441 #ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 1442 ohciR3PhysReadCacheRead(pThis, pThis->pCacheED, EdAddr, pEd, sizeof(*pEd)); 1443 #else 1452 1444 ohciR3GetDWords(pThis, EdAddr, (uint32_t *)pEd, sizeof(*pEd) >> 2); 1445 #endif 1453 1446 } 1454 1447 … … 1462 1455 physReadStatsUpdateDesc(&g_PhysReadState.all, TdAddr); 1463 1456 # endif 1457 #ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 1458 ohciR3PhysReadCacheRead(pThis, pThis->pCacheTD, TdAddr, pTd, sizeof(*pTd)); 1459 #else 1464 1460 ohciR3GetDWords(pThis, TdAddr, (uint32_t *)pTd, sizeof(*pTd) >> 2); 1461 #endif 1465 1462 # ifdef LOG_ENABLED 1466 1463 if (LogIs3Enabled()) … … 1572 1569 # endif 1573 1570 1574 ohciR3PutDWords(pThis, EdAddr , (uint32_t *)pEd, sizeof(*pEd) >> 2);1571 ohciR3PutDWords(pThis, EdAddr + RT_OFFSETOF(OHCIED, HeadP), &pEd->HeadP, 1); 1575 1572 #ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 1576 1573 ohciR3CacheEdUpdate(pThis, EdAddr, pEd); … … 2417 2414 } 2418 2415 } 2416 2417 2418 /** 2419 * Lock the given OHCI controller instance. 2420 * 2421 * @returns nothing. 2422 * @param pThis The OHCI controller instance to lock. 2423 */ 2424 DECLINLINE(void) ohciR3Lock(POHCI pThis) 2425 { 2426 RTCritSectEnter(&pThis->CritSect); 2427 2428 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 2429 /* Clear all caches here to avoid reading stale data from previous lock holders. */ 2430 ohciR3PhysReadCacheClear(pThis->pCacheED); 2431 ohciR3PhysReadCacheClear(pThis->pCacheTD); 2432 # endif 2433 } 2434 2435 2436 /** 2437 * Unlocks the given OHCI controller instance. 2438 * 2439 * @returns nothing. 2440 * @param pThis The OHCI controller instance to unlock. 2441 */ 2442 DECLINLINE(void) ohciR3Unlock(POHCI pThis) 2443 { 2444 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 2445 /* 2446 * Clear all caches here to avoid leaving stale data behind (paranoia^2, 2447 * already done in ohciR3Lock). 2448 */ 2449 ohciR3PhysReadCacheClear(pThis->pCacheED); 2450 ohciR3PhysReadCacheClear(pThis->pCacheTD); 2451 # endif 2452 2453 RTCritSectLeave(&pThis->CritSect); 2454 } 2455 2419 2456 2420 2457 /** … … 2724 2761 pUrb->pszDesc, pUrb->pHci->EdAddr, pUrb->pHci->cTds, pUrb->paTds[0].TdAddr)); 2725 2762 2726 RTCritSectEnter(&pThis->CritSect);2763 ohciR3Lock(pThis); 2727 2764 pThis->fIdle = false; /* Mark as active */ 2728 2765 … … 2748 2785 pUrb->pszDesc, pUrb->pHci->EdAddr, pUrb->pHci->cTds, pUrb->paTds[0].TdAddr, cFmAge)); 2749 2786 STAM_COUNTER_INC(&pThis->StatDroppedUrbs); 2750 RTCritSectLeave(&pThis->CritSect);2787 ohciR3Unlock(pThis); 2751 2788 return; 2752 2789 } … … 2768 2805 NOREF(fHasBeenCanceled); 2769 2806 STAM_COUNTER_INC(&pThis->StatDroppedUrbs); 2770 RTCritSectLeave(&pThis->CritSect);2807 ohciR3Unlock(pThis); 2771 2808 return; 2772 2809 } … … 2783 2820 /* finally write back the endpoint descriptor. */ 2784 2821 ohciR3WriteEd(pThis, pUrb->pHci->EdAddr, &Ed); 2785 2786 RTCritSectLeave(&pThis->CritSect); 2822 ohciR3Unlock(pThis); 2787 2823 } 2788 2824 … … 2818 2854 } 2819 2855 2820 RTCritSectEnter(&pThis->CritSect); 2821 2856 ohciR3Lock(pThis); 2822 2857 bool fRetire = false; 2823 2858 /* … … 2853 2888 } 2854 2889 2855 RTCritSectLeave(&pThis->CritSect);2890 ohciR3Unlock(pThis); 2856 2891 return fRetire; 2857 2892 } … … 2937 2972 pUrb->pszDesc, TdAddr, EdAddr, pUrb->cbData)); 2938 2973 2939 RTCritSectLeave(&pThis->CritSect);2974 ohciR3Unlock(pThis); 2940 2975 int rc = VUSBIRhSubmitUrb(pThis->RootHub.pIRhConn, pUrb, &pThis->RootHub.Led); 2941 RTCritSectEnter(&pThis->CritSect);2976 ohciR3Lock(pThis); 2942 2977 if (RT_SUCCESS(rc)) 2943 2978 return true; … … 2997 3032 2998 3033 /* read the head */ 2999 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE3000 ohciR3ReadTdCached(pThis, TdAddr, &Head.Td);3001 # else3002 3034 ohciR3ReadTd(pThis, TdAddr, &Head.Td); 3003 # endif3004 3035 ohciR3BufInit(&Head.Buf, Head.Td.cbp, Head.Td.be); 3005 3036 Head.TdAddr = TdAddr; … … 3019 3050 pCur->pNext = NULL; 3020 3051 pCur->TdAddr = pTail->Td.NextTD & ED_PTR_MASK; 3021 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE3022 ohciR3ReadTdCached(pThis, pCur->TdAddr, &pCur->Td);3023 # else3024 3052 ohciR3ReadTd(pThis, pCur->TdAddr, &pCur->Td); 3025 # endif3026 3053 ohciR3BufInit(&pCur->Buf, pCur->Td.cbp, pCur->Td.be); 3027 3054 … … 3114 3141 Log(("%s: ohciR3ServiceTdMultiple: submitting cbData=%#x EdAddr=%#010x cTds=%d TdAddr0=%#010x\n", 3115 3142 pUrb->pszDesc, pUrb->cbData, EdAddr, cTds, TdAddr)); 3116 RTCritSectLeave(&pThis->CritSect);3143 ohciR3Unlock(pThis); 3117 3144 int rc = VUSBIRhSubmitUrb(pThis->RootHub.pIRhConn, pUrb, &pThis->RootHub.Led); 3118 RTCritSectEnter(&pThis->CritSect);3145 ohciR3Lock(pThis); 3119 3146 if (RT_SUCCESS(rc)) 3120 3147 return true; … … 3341 3368 Log(("%s: ohciR3ServiceIsochronousTd: submitting cbData=%#x cIsocPkts=%d EdAddr=%#010x TdAddr=%#010x SF=%#x (%#x)\n", 3342 3369 pUrb->pszDesc, pUrb->cbData, pUrb->cIsocPkts, EdAddr, ITdAddr, pITd->HwInfo & ITD_HWINFO_SF, pThis->HcFmNumber)); 3343 RTCritSectLeave(&pThis->CritSect);3370 ohciR3Unlock(pThis); 3344 3371 int rc = VUSBIRhSubmitUrb(pThis->RootHub.pIRhConn, pUrb, &pThis->RootHub.Led); 3345 RTCritSectEnter(&pThis->CritSect);3372 ohciR3Lock(pThis); 3346 3373 if (RT_SUCCESS(rc)) 3347 3374 return true; … … 3529 3556 { 3530 3557 OHCIED Ed; 3531 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE3532 ohciR3ReadEdCached(pThis, EdAddr, &Ed);3533 # else3534 3558 ohciR3ReadEd(pThis, EdAddr, &Ed); 3535 # endif3536 3559 Assert(!(Ed.hwinfo & ED_HWINFO_ISO)); /* the guest is screwing us */ 3537 3560 if (ohciR3IsEdReady(&Ed)) … … 3627 3650 { 3628 3651 OHCIED Ed; 3629 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 3630 ohciR3ReadEdCached(pThis, EdAddr, &Ed); 3631 # else 3652 3632 3653 ohciR3ReadEd(pThis, EdAddr, &Ed); 3633 # endif3634 3654 Assert(!(Ed.hwinfo & ED_HWINFO_ISO)); /* the guest is screwing us */ 3635 3655 if (ohciR3IsEdPresent(&Ed)) … … 3748 3768 { 3749 3769 OHCIED Ed; 3750 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 3751 ohciR3ReadEdCached(pThis, EdAddr, &Ed); 3752 # else 3770 3753 3771 ohciR3ReadEd(pThis, EdAddr, &Ed); 3754 # endif3755 3756 3772 if (ohciR3IsEdReady(&Ed)) 3757 3773 { … … 3916 3932 OHCIED Ed; 3917 3933 OHCITD Td; 3918 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE 3919 ohciR3ReadEdCached(pThis, EdAddr, &Ed); 3920 # else 3934 3921 3935 ohciR3ReadEd(pThis, EdAddr, &Ed); 3922 # endif3923 3936 uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK; 3924 3937 uint32_t TailP = Ed.TailP & ED_PTR_MASK; … … 3932 3945 do 3933 3946 { 3934 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE3935 ohciR3ReadTdCached(pThis, TdAddr, &Td);3936 # else3937 3947 ohciR3ReadTd(pThis, TdAddr, &Td); 3938 # endif3939 3948 j = ohciR3InFlightFind(pThis, TdAddr); 3940 3949 if (j > -1) … … 4099 4108 POHCI pThis = VUSBIROOTHUBPORT_2_OHCI(pInterface); 4100 4109 4101 RTCritSectEnter(&pThis->CritSect);4110 ohciR3Lock(pThis); 4102 4111 4103 4112 /* Reset idle detection flag */ … … 4106 4115 # ifdef VBOX_WITH_OHCI_PHYS_READ_STATS 4107 4116 physReadStatsReset(&g_PhysReadState); 4108 # endif4109 4110 # ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE4111 ohciR3PhysReadCacheClear(pThis->pCacheED);4112 ohciR3PhysReadCacheClear(pThis->pCacheTD);4113 4117 # endif 4114 4118 … … 4128 4132 # endif 4129 4133 4130 RTCritSectLeave(&pThis->CritSect); 4131 4134 ohciR3Unlock(pThis); 4132 4135 return pThis->fIdle; 4133 4136 }
Note:
See TracChangeset
for help on using the changeset viewer.

