Changeset 50782 in vbox for trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
- Timestamp:
- Mar 14, 2014 3:36:19 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
r50781 r50782 100 100 #define DRIVER_NAME "vboxpci" 101 101 102 /* 103 * Currently we keep the device bound to pci stub driver, so 104 * dev_printk() &co would report that instead of our name. They also 105 * expect non-NULL dev pointer in older kernels. 106 */ 107 #define vbpci_printk(level, pdev, format, arg...) \ 108 printk(level DRIVER_NAME "%s%s: " format, \ 109 pdev ? " " : "", pdev ? pci_name(pdev) : "", \ 110 ## arg) 111 112 102 113 /** 103 114 * Initialize module. … … 198 209 int rc; 199 210 int status; 211 struct pci_dev *pPciDev = pIns->pPciDev; 200 212 PVBOXRAWPCIDRVVM pData = VBOX_DRV_VMDATA(pIns); 201 213 202 214 if (!pData) 203 215 { 204 printk(KERN_DEBUG "vboxpci: VM data not initialized (attach)\n"); 216 vbpci_printk(KERN_DEBUG, pPciDev, 217 "cannot attach to IOMMU, no VM data\n"); 205 218 return VERR_INVALID_PARAMETER; 206 219 } … … 208 221 if (!pData->pIommuDomain) 209 222 { 210 printk(KERN_DEBUG "vboxpci: No IOMMU domain (attach)\n"); 223 vbpci_printk(KERN_DEBUG, pIns->pPciDev, 224 "cannot attach to IOMMU, no domain\n"); 211 225 return VERR_NOT_FOUND; 212 226 } 213 227 214 status = iommu_attach_device(pData->pIommuDomain, &p Ins->pPciDev->dev);228 status = iommu_attach_device(pData->pIommuDomain, &pPciDev->dev); 215 229 if (status == 0) 216 230 { 217 printk(KERN_DEBUG "vboxpci: iommu_attach_device() success\n");231 vbpci_printk(KERN_DEBUG, pPciDev, "attached to IOMMU\n"); 218 232 pIns->fIommuUsed = true; 219 233 rc = VINF_SUCCESS; … … 221 235 else 222 236 { 223 printk(KERN_DEBUG "vboxpci: iommu_attach_device() failed\n"); 237 vbpci_printk(KERN_DEBUG, pPciDev, 238 "failed to attach to IOMMU, error %d\n", status); 224 239 rc = VERR_INTERNAL_ERROR; 225 240 } … … 239 254 #ifdef VBOX_WITH_IOMMU 240 255 int rc = VINF_SUCCESS; 256 struct pci_dev *pPciDev = pIns->pPciDev; 241 257 PVBOXRAWPCIDRVVM pData = VBOX_DRV_VMDATA(pIns); 242 258 243 259 if (!pData) 244 260 { 245 printk(KERN_DEBUG "vboxpci: VM data not inited (detach)\n"); 261 vbpci_printk(KERN_DEBUG, pPciDev, 262 "cannot detach from IOMMU, no VM data\n"); 246 263 return VERR_INVALID_PARAMETER; 247 264 } … … 249 266 if (!pData->pIommuDomain) 250 267 { 251 printk(KERN_DEBUG "vboxpci: No IOMMU domain (detach)\n"); 268 vbpci_printk(KERN_DEBUG, pPciDev, 269 "cannot detach from IOMMU, no domain\n"); 252 270 return VERR_NOT_FOUND; 253 271 } … … 256 274 { 257 275 iommu_detach_device(pData->pIommuDomain, &pIns->pPciDev->dev); 258 printk(KERN_DEBUG "vboxpci: iommu_detach_device()\n");276 vbpci_printk(KERN_DEBUG, pPciDev, "detached from IOMMU\n"); 259 277 pIns->fIommuUsed = false; 260 278 } … … 628 646 if (pci_enable_msi(pPciDev) == 0) 629 647 { 630 printk(KERN_DEBUG "vboxpci:enabled MSI\n");648 vbpci_printk(KERN_DEBUG, pPciDev, "enabled MSI\n"); 631 649 pIns->fMsiUsed = true; 632 650 } … … 644 662 int vboxPciOsDevDeinit(PVBOXRAWPCIINS pIns, uint32_t fFlags) 645 663 { 646 struct pci_dev *pPciDev = NULL; 647 648 printk(KERN_DEBUG "vboxpci: vboxPciOsDevDeinit: dev=%x\n", pIns->HostPciAddress); 649 650 pPciDev = pIns->pPciDev; 664 struct pci_dev *pPciDev = pIns->pPciDev; 665 666 vbpci_printk(KERN_DEBUG, pPciDev, "%s\n", __func__); 651 667 652 668 if (pPciDev) … … 702 718 } 703 719 704 printk(KERN_DEBUG "%x: linux vboxPciOsDevGetRegionInfo: reg=%d\n",705 pIns->HostPciAddress, iRegion);706 707 720 flags = pci_resource_flags(pPciDev, iRegion); 708 721 if (((flags & (IORESOURCE_MEM | IORESOURCE_IO)) == 0) … … 735 748 *pu64RegionSize = pci_resource_len (pPciDev, iRegion); 736 749 737 printk(KERN_DEBUG "got %s region: %llx:%lld\n", 738 (flags & IORESOURCE_MEM) ? "mmio" : "pio", *pRegionStart, *pu64RegionSize); 750 vbpci_printk(KERN_DEBUG, pPciDev, 751 "region %d: %s %llx+%lld\n", 752 iRegion, (flags & IORESOURCE_MEM) ? "mmio" : "pio", 753 *pRegionStart, *pu64RegionSize); 739 754 740 755 return 0; … … 894 909 if (iIrq == 0) 895 910 { 896 printk(KERN_DEBUG "device not assigned host interrupt\n");911 vbpci_printk(KERN_NOTICE, pIns->pPciDev, "no irq assigned\n"); 897 912 return VERR_INVALID_PARAMETER; 898 913 } … … 921 936 if (rc) 922 937 { 923 printk(KERN_DEBUG "could not request IRQ %d: err=%d\n", iIrq, rc); 938 vbpci_printk(KERN_DEBUG, pIns->pPciDev, 939 "could not request irq %d, error %d\n", iIrq, rc); 924 940 return VERR_RESOURCE_BUSY; 925 941 } 926 942 927 printk(KERN_DEBUG "got PCI IRQ:%d\n", iIrq);943 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "got irq %d\n", iIrq); 928 944 *piHostIrq = iIrq; 929 945 return VINF_SUCCESS; … … 932 948 int vboxPciOsDevUnregisterIrqHandler(PVBOXRAWPCIINS pIns, int32_t iHostIrq) 933 949 { 934 printk(KERN_DEBUG "free PCI IRQ:%d\n", iHostIrq);950 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "freeing irq %d\n", iHostIrq); 935 951 free_irq(iHostIrq, pIns); 936 952 return VINF_SUCCESS; … … 941 957 int rc; 942 958 943 printk(KERN_DEBUG "power state: %d\n", (int)aState);944 945 959 switch (aState) 946 960 { 947 961 case PCIRAW_POWER_ON: 962 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_ON\n"); 948 963 /* Reset device, just in case. */ 949 964 vboxPciOsDevReset(pIns); … … 952 967 break; 953 968 case PCIRAW_POWER_RESET: 969 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_RESET\n"); 954 970 rc = vboxPciOsDevReset(pIns); 955 971 break; 956 972 case PCIRAW_POWER_OFF: 973 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_OFF\n"); 957 974 /* unregister us from IOMMU */ 958 975 rc = vboxPciOsDevUnregisterWithIommu(pIns); 959 976 break; 960 977 case PCIRAW_POWER_SUSPEND: 961 case PCIRAW_POWER_RESUME:978 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_SUSPEND\n"); 962 979 rc = VINF_SUCCESS; 963 980 /// @todo: what do we do here? 964 981 break; 982 case PCIRAW_POWER_RESUME: 983 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_RESUME\n"); 984 rc = VINF_SUCCESS; 985 /// @todo: what do we do here? 986 break; 965 987 default: 988 vbpci_printk(KERN_DEBUG, pIns->pPciDev, "unknown power state %u\n", aState); 966 989 /* to make compiler happy */ 967 990 rc = VERR_NOT_SUPPORTED; … … 1023 1046 int vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM, PRAWPCIPERVM pVmData) 1024 1047 { 1025 #ifdef DEBUG1026 printk(KERN_DEBUG "vboxPciOsInitVm: %p\n", pThis);1027 #endif1028 1048 #ifdef VBOX_WITH_IOMMU 1029 1049 if (IOMMU_PRESENT()) … … 1032 1052 if (!pThis->pIommuDomain) 1033 1053 { 1034 printk(KERN_DEBUG"cannot allocate IOMMU domain\n");1054 vbpci_printk(KERN_DEBUG, NULL, "cannot allocate IOMMU domain\n"); 1035 1055 return VERR_NO_MEMORY; 1036 1056 } … … 1038 1058 pVmData->pfnContigMemInfo = vboxPciOsContigMemInfo; 1039 1059 1040 printk(KERN_DEBUG "created IOMMU domain %p\n", pThis->pIommuDomain); 1060 vbpci_printk(KERN_DEBUG, NULL, "created IOMMU domain %p\n", 1061 pThis->pIommuDomain); 1041 1062 } 1042 1063 #endif … … 1046 1067 void vboxPciOsDeinitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM) 1047 1068 { 1048 #ifdef DEBUG1049 printk(KERN_DEBUG "vboxPciOsDeinitVm: %p\n", pThis);1050 #endif1051 1069 #ifdef VBOX_WITH_IOMMU 1052 1070 if (pThis->pIommuDomain) 1053 1071 { 1072 vbpci_printk(KERN_DEBUG, NULL, "freeing IOMMU domain %p\n", 1073 pThis->pIommuDomain); 1054 1074 iommu_domain_free(pThis->pIommuDomain); 1055 1075 pThis->pIommuDomain = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.