VirtualBox

Changeset 58091 in vbox for trunk


Ignore:
Timestamp:
Oct 7, 2015 1:28:38 PM (9 years ago)
Author:
vboxsync
Message:

pciraw: integrate the changes to make MSI work, and assorted fixes and cleanups

Location:
trunk/src/VBox/Devices/Bus
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r57781 r58091  
    921921                uNew = INVALID_PCI_ADDRESS;
    922922        }
    923         //LogRel(("PCI: config dev %u/%u BAR%i uOld=%#018llx uNew=%#018llx size=%llu\n", pDev->devfn >> 3, pDev->devfn & 7, iRegion, pRegion->addr, uNew, pRegion->size));
     923        LogRel2(("PCI: config dev %u/%u BAR%i uOld=%#018llx uNew=%#018llx size=%llu\n", pDev->devfn >> 3, pDev->devfn & 7, iRegion, pRegion->addr, uNew, pRegion->size));
    924924        /* now do the real mapping */
    925925        if (uNew != pRegion->addr)
  • trunk/src/VBox/Devices/Bus/MsiCommon.cpp

    r56292 r58091  
    2525#include "MsiCommon.h"
    2626
    27 /** @todo: use accessors so that raw PCI devices work correctly with MSI. */
    2827DECLINLINE(uint16_t) msiGetMessageControl(PPCIDEVICE pDev)
    2928{
    30     return PCIDevGetWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL);
     29    uint32_t idxMessageControl = pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL;
     30#ifdef IN_RING3
     31    if (pciDevIsPassthrough(pDev)) {
     32        return pDev->Int.s.pfnConfigRead(pDev, idxMessageControl, 2);
     33    }
     34#endif
     35    return PCIDevGetWord(pDev, idxMessageControl);
    3136}
    3237
     
    3944{
    4045    uint8_t iOff = msiIs64Bit(pDev) ? VBOX_MSI_CAP_MASK_BITS_64 : VBOX_MSI_CAP_MASK_BITS_32;
     46    /* passthrough devices may have no masked/pending support */
     47    if (iOff >= pDev->Int.s.u8MsiCapSize)
     48        return NULL;
    4149    iOff += pDev->Int.s.u8MsiCapOffset;
    4250    return (uint32_t*)(pDev->config + iOff);
     
    4654{
    4755    uint8_t iOff = msiIs64Bit(pDev) ? VBOX_MSI_CAP_PENDING_BITS_64 : VBOX_MSI_CAP_PENDING_BITS_32;
     56    /* passthrough devices may have no masked/pending support */
     57    if (iOff >= pDev->Int.s.u8MsiCapSize)
     58        return NULL;
    4859    iOff += pDev->Int.s.u8MsiCapOffset;
    4960    return (uint32_t*)(pDev->config + iOff);
     
    220231         return VINF_SUCCESS;
    221232
    222     /* We cannot init MSI on raw devices yet. */
    223     Assert(!pciDevIsPassthrough(pDev));
     233    /* XXX: done in pcirawAnalyzePciCaps() */
     234    if (pciDevIsPassthrough(pDev))
     235        return VINF_SUCCESS;
    224236
    225237    uint16_t   cVectors    = pMsiReg->cMsiVectors;
     
    276288    AssertMsg(msiIsEnabled(pDev), ("Must be enabled to use that"));
    277289
    278     uint32_t   uMask = *msiGetMaskBits(pDev);
    279     uint32_t*  puPending = msiGetPendingBits(pDev);
    280 
    281     LogFlow(("MsiNotify: %d pending=%x mask=%x\n", iVector, *puPending, uMask));
     290    uint32_t uMask;
     291    uint32_t *puPending = msiGetPendingBits(pDev);
     292    if (puPending)
     293    {
     294        uint32_t *puMask = msiGetMaskBits(pDev);
     295        AssertPtr(puMask);
     296        uMask = *puMask;
     297        LogFlow(("MsiNotify: %d pending=%x mask=%x\n", iVector, *puPending, uMask));
     298    }
     299    else
     300    {
     301        uMask = 0;
     302        LogFlow(("MsiNotify: %d\n", iVector));
     303    }
    282304
    283305    /* We only trigger MSI on level up */
     
    286308        /* @todo: maybe clear pending interrupts on level down? */
    287309#if 0
    288         *puPending &= ~(1<<iVector);
    289         LogFlow(("msi: clear pending %d, now %x\n", iVector, *puPending));
     310        if (puPending)
     311        {
     312            *puPending &= ~(1<<iVector);
     313            LogFlow(("msi: clear pending %d, now %x\n", iVector, *puPending));
     314        }
    290315#endif
    291316        return;
     
    302327    uint32_t   u32Value = msiGetMsiData(pDev, iVector);
    303328
    304     *puPending &= ~(1<<iVector);
     329    if (puPending)
     330        *puPending &= ~(1<<iVector);
    305331
    306332    Assert(pPciHlp->pfnIoApicSendMsi != NULL);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette