Screwing around with lirc, I somehow disabled busmastering on my ivtv cards. Of course, once this happens, ivtv will fail to load since busmastering is required. This simple patch attempts to enable bus mastering on the device if it isn't on when the module loads. I also added a line to pci_disable_device() when we cleanup, since we're supposed to be doing that on any card we pci_enable_device() on. It also should be added to ivtv_probe()'s failure code, but I'm not sure where to put it exactly (ivtv_setup_pci() might fail on the enable call or after the enable call, so we can't tell if we need to disable based on the return value).
Index: driver/ivtv-driver.c
===================================================================
--- driver/ivtv-driver.c        (revision 337)
+++ driver/ivtv-driver.c        (working copy)
@@ -829,11 +829,15 @@
        /* Check for bus mastering */
        pci_read_config_word(dev, PCI_COMMAND, &cmd);
        if (!(cmd & PCI_COMMAND_MASTER)) {
-               IVTV_KERN_ERR("Bus Mastering is not enabled\n");
-               return -ENXIO;
-       } else {
-               IVTV_DEBUG(IVTV_DEBUG_INFO, "Bus Mastering Enabled.");
-       }
+               IVTV_KERN_ERR("Attempting to enable Bus Mastering\n");
+               pci_set_master(dev);
+               pci_read_config_word(dev, PCI_COMMAND, &cmd);
+               if (!(cmd & PCI_COMMAND_MASTER)) {
+                       IVTV_KERN_ERR("Bus Mastering is not enabled\n");
+                       return -ENXIO;
+               }
+       } 
+       IVTV_DEBUG(IVTV_DEBUG_INFO, "Bus Mastering Enabled.");
 
        pci_read_config_byte(dev, PCI_CLASS_REVISION, &itv->card_rev);
        pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
@@ -1304,6 +1308,8 @@
        IVTV_DEBUG(IVTV_DEBUG_INFO, " Releasing mem.\n");
        release_mem_region(pci_resource_start(itv->dev, 0), IVTV_IOREMAP_SIZE);
 
+       pci_disable_device(itv->dev);
+
        IVTV_KERN_INFO("Removed %s, card #%d\n", itv->card->name, itv->num);
 }
 

Reply via email to