Index: /trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c	(revision 50781)
+++ /trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c	(revision 50782)
@@ -100,4 +100,15 @@
 #define DRIVER_NAME      "vboxpci"
 
+/*
+ * Currently we keep the device bound to pci stub driver, so
+ * dev_printk() &co would report that instead of our name. They also
+ * expect non-NULL dev pointer in older kernels.
+ */
+#define vbpci_printk(level, pdev, format, arg...)               \
+       printk(level DRIVER_NAME "%s%s: " format,                \
+              pdev ? " " : "", pdev ? pci_name(pdev) : "",      \
+              ## arg)
+
+
 /**
  * Initialize module.
@@ -198,9 +209,11 @@
     int rc;
     int status;
+    struct pci_dev *pPciDev = pIns->pPciDev;
     PVBOXRAWPCIDRVVM pData = VBOX_DRV_VMDATA(pIns);
 
     if (!pData)
     {
-        printk(KERN_DEBUG "vboxpci: VM data not initialized (attach)\n");
+        vbpci_printk(KERN_DEBUG, pPciDev,
+                     "cannot attach to IOMMU, no VM data\n");
         return VERR_INVALID_PARAMETER;
     }
@@ -208,12 +221,13 @@
     if (!pData->pIommuDomain)
     {
-        printk(KERN_DEBUG "vboxpci: No IOMMU domain (attach)\n");
+        vbpci_printk(KERN_DEBUG, pIns->pPciDev,
+                     "cannot attach to IOMMU, no domain\n");
         return VERR_NOT_FOUND;
     }
 
-    status = iommu_attach_device(pData->pIommuDomain, &pIns->pPciDev->dev);
+    status = iommu_attach_device(pData->pIommuDomain, &pPciDev->dev);
     if (status == 0)
     {
-        printk(KERN_DEBUG "vboxpci: iommu_attach_device() success\n");
+        vbpci_printk(KERN_DEBUG, pPciDev, "attached to IOMMU\n");
         pIns->fIommuUsed = true;
         rc = VINF_SUCCESS;
@@ -221,5 +235,6 @@
     else
     {
-        printk(KERN_DEBUG "vboxpci: iommu_attach_device() failed\n");
+        vbpci_printk(KERN_DEBUG, pPciDev,
+                     "failed to attach to IOMMU, error %d\n", status);
         rc = VERR_INTERNAL_ERROR;
     }
@@ -239,9 +254,11 @@
 #ifdef VBOX_WITH_IOMMU
     int rc = VINF_SUCCESS;
+    struct pci_dev *pPciDev = pIns->pPciDev;
     PVBOXRAWPCIDRVVM pData = VBOX_DRV_VMDATA(pIns);
 
     if (!pData)
     {
-        printk(KERN_DEBUG "vboxpci: VM data not inited (detach)\n");
+        vbpci_printk(KERN_DEBUG, pPciDev,
+                     "cannot detach from IOMMU, no VM data\n");
         return VERR_INVALID_PARAMETER;
     }
@@ -249,5 +266,6 @@
     if (!pData->pIommuDomain)
     {
-        printk(KERN_DEBUG "vboxpci: No IOMMU domain (detach)\n");
+        vbpci_printk(KERN_DEBUG, pPciDev,
+                     "cannot detach from IOMMU, no domain\n");
         return VERR_NOT_FOUND;
     }
@@ -256,5 +274,5 @@
     {
         iommu_detach_device(pData->pIommuDomain, &pIns->pPciDev->dev);
-        printk(KERN_DEBUG "vboxpci: iommu_detach_device()\n");
+        vbpci_printk(KERN_DEBUG, pPciDev, "detached from IOMMU\n");
         pIns->fIommuUsed = false;
     }
@@ -628,5 +646,5 @@
     if (pci_enable_msi(pPciDev) == 0)
     {
-        printk(KERN_DEBUG "vboxpci: enabled MSI\n");
+        vbpci_printk(KERN_DEBUG, pPciDev, "enabled MSI\n");
         pIns->fMsiUsed = true;
     }
@@ -644,9 +662,7 @@
 int  vboxPciOsDevDeinit(PVBOXRAWPCIINS pIns, uint32_t fFlags)
 {
-    struct pci_dev *pPciDev = NULL;
-
-    printk(KERN_DEBUG "vboxpci: vboxPciOsDevDeinit: dev=%x\n", pIns->HostPciAddress);
-
-    pPciDev = pIns->pPciDev;
+    struct pci_dev *pPciDev = pIns->pPciDev;
+
+    vbpci_printk(KERN_DEBUG, pPciDev, "%s\n", __func__);
 
     if (pPciDev)
@@ -702,7 +718,4 @@
     }
 
-    printk(KERN_DEBUG "%x: linux vboxPciOsDevGetRegionInfo: reg=%d\n",
-           pIns->HostPciAddress, iRegion);
-
     flags = pci_resource_flags(pPciDev, iRegion);
     if (((flags & (IORESOURCE_MEM | IORESOURCE_IO)) == 0)
@@ -735,6 +748,8 @@
     *pu64RegionSize = pci_resource_len  (pPciDev, iRegion);
 
-    printk(KERN_DEBUG "got %s region: %llx:%lld\n",
-           (flags & IORESOURCE_MEM) ? "mmio" : "pio", *pRegionStart, *pu64RegionSize);
+    vbpci_printk(KERN_DEBUG, pPciDev,
+                 "region %d: %s %llx+%lld\n",
+                 iRegion, (flags & IORESOURCE_MEM) ? "mmio" : "pio",
+                 *pRegionStart, *pu64RegionSize);
 
     return 0;
@@ -894,5 +909,5 @@
     if (iIrq == 0)
     {
-        printk(KERN_DEBUG "device not assigned host interrupt\n");
+        vbpci_printk(KERN_NOTICE, pIns->pPciDev, "no irq assigned\n");
         return VERR_INVALID_PARAMETER;
     }
@@ -921,9 +936,10 @@
     if (rc)
     {
-        printk(KERN_DEBUG "could not request IRQ %d: err=%d\n", iIrq, rc);
+        vbpci_printk(KERN_DEBUG, pIns->pPciDev,
+                     "could not request irq %d, error %d\n", iIrq, rc);
         return VERR_RESOURCE_BUSY;
     }
 
-    printk(KERN_DEBUG "got PCI IRQ: %d\n", iIrq);
+    vbpci_printk(KERN_DEBUG, pIns->pPciDev, "got irq %d\n", iIrq);
     *piHostIrq = iIrq;
     return VINF_SUCCESS;
@@ -932,5 +948,5 @@
 int vboxPciOsDevUnregisterIrqHandler(PVBOXRAWPCIINS pIns, int32_t iHostIrq)
 {
-    printk(KERN_DEBUG "free PCI IRQ: %d\n", iHostIrq);
+    vbpci_printk(KERN_DEBUG, pIns->pPciDev, "freeing irq %d\n", iHostIrq);
     free_irq(iHostIrq, pIns);
     return VINF_SUCCESS;
@@ -941,9 +957,8 @@
     int rc;
 
-    printk(KERN_DEBUG "power state: %d\n", (int)aState);
-
     switch (aState)
     {
         case PCIRAW_POWER_ON:
+            vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_ON\n");
             /* Reset device, just in case. */
             vboxPciOsDevReset(pIns);
@@ -952,16 +967,24 @@
             break;
         case PCIRAW_POWER_RESET:
+            vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_RESET\n");
             rc = vboxPciOsDevReset(pIns);
             break;
         case PCIRAW_POWER_OFF:
+            vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_OFF\n");
             /* unregister us from IOMMU */
             rc = vboxPciOsDevUnregisterWithIommu(pIns);
             break;
         case PCIRAW_POWER_SUSPEND:
-        case PCIRAW_POWER_RESUME:
+            vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_SUSPEND\n");
             rc = VINF_SUCCESS;
             /// @todo: what do we do here?
             break;
+        case PCIRAW_POWER_RESUME:
+            vbpci_printk(KERN_DEBUG, pIns->pPciDev, "PCIRAW_POWER_RESUME\n");
+            rc = VINF_SUCCESS;
+            /// @todo: what do we do here?
+            break;
         default:
+            vbpci_printk(KERN_DEBUG, pIns->pPciDev, "unknown power state %u\n", aState);
             /* to make compiler happy */
             rc = VERR_NOT_SUPPORTED;
@@ -1023,7 +1046,4 @@
 int  vboxPciOsInitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM, PRAWPCIPERVM pVmData)
 {
-#ifdef DEBUG
-    printk(KERN_DEBUG "vboxPciOsInitVm: %p\n", pThis);
-#endif
 #ifdef VBOX_WITH_IOMMU
     if (IOMMU_PRESENT())
@@ -1032,5 +1052,5 @@
         if (!pThis->pIommuDomain)
         {
-            printk(KERN_DEBUG "cannot allocate IOMMU domain\n");
+            vbpci_printk(KERN_DEBUG, NULL, "cannot allocate IOMMU domain\n");
             return VERR_NO_MEMORY;
         }
@@ -1038,5 +1058,6 @@
         pVmData->pfnContigMemInfo = vboxPciOsContigMemInfo;
 
-        printk(KERN_DEBUG "created IOMMU domain %p\n", pThis->pIommuDomain);
+        vbpci_printk(KERN_DEBUG, NULL, "created IOMMU domain %p\n",
+                     pThis->pIommuDomain);
     }
 #endif
@@ -1046,10 +1067,9 @@
 void vboxPciOsDeinitVm(PVBOXRAWPCIDRVVM pThis, PVM pVM)
 {
-#ifdef DEBUG
-    printk(KERN_DEBUG "vboxPciOsDeinitVm: %p\n", pThis);
-#endif
 #ifdef VBOX_WITH_IOMMU
     if (pThis->pIommuDomain)
     {
+        vbpci_printk(KERN_DEBUG, NULL, "freeing IOMMU domain %p\n",
+                     pThis->pIommuDomain);
         iommu_domain_free(pThis->pIommuDomain);
         pThis->pIommuDomain = NULL;
