--- NVIDIA-Linux-x86-1.0-6111-pkg1/usr/src/nv/nv.c.orig 2004-10-27 18:24:52.617102752 +0200 +++ NVIDIA-Linux-x86-1.0-6111-pkg1/usr/src/nv/nv.c 2004-10-27 18:26:34.998538408 +0200 @@ -1225,6 +1225,7 @@ { nv_state_t *nv = NV_STATE_PTR(&nv_linux_devices[i]); release_mem_region(nv->bar.regs.address, nv->bar.regs.size); + pci_disable_device(nv_linux_devices[i].dev); } } @@ -3517,6 +3518,28 @@ return -1; } + // enable io, mem, and bus-mastering in pci config space + if (pci_enable_device(dev) != 0) + { + nv_printf(NV_DBG_ERRORS, + "NVRM: pci_enable_device failed, aborting\n"); + return -1; + } + + // request ownership of our bars + // keeps other drivers from banging our registers. + // only do this for registers, as vesafb requests our framebuffer and will + // keep us from working properly + if (!request_mem_region(dev->resource[0].start, + dev->resource[0].end - dev->resource[0].start + 1, + "nvidia")) + { + nv_printf(NV_DBG_ERRORS, + "NVRM: pci_request_regions failed, aborting\n"); + goto err_disable_dev; + } + pci_set_master(dev); + /* initialize bus-dependent config state */ nvl = &nv_linux_devices[num_nv_devices]; nv = NV_STATE_PTR(nvl); @@ -3546,7 +3569,7 @@ nv_printf(NV_DBG_ERRORS, "NVRM: Please check your BIOS settings. \n"); nv_printf(NV_DBG_ERRORS, "NVRM: [Plug & Play OS ] should be set to NO \n"); nv_printf(NV_DBG_ERRORS, "NVRM: [Assign IRQ to VGA] should be set to YES \n"); - return -1; + goto err_zero_dev; } /* sanity check the IO apertures */ @@ -3570,39 +3593,9 @@ nv->bar.fb.address, nv->bar.fb.size); } - /* Clear out the data */ - os_mem_set(nvl, 0, sizeof(nv_linux_state_t)); - - return -1; - } - - // request ownership of our bars - // keeps other drivers from banging our registers. - // only do this for registers, as vesafb requests our framebuffer and will - // keep us from working properly - if (!request_mem_region(nv->bar.regs.address, nv->bar.regs.size, "nvidia")) - { - nv_printf(NV_DBG_ERRORS, - "NVRM: pci_request_regions failed, aborting\n"); - - /* Clear out the data */ - os_mem_set(nvl, 0, sizeof(nv_linux_state_t)); - - return -1; + goto err_zero_dev; } - // enable io, mem, and bus-mastering in pci config space - if (pci_enable_device(dev) != 0) - { - nv_printf(NV_DBG_ERRORS, - "NVRM: pci_enable_device failed, aborting\n"); - - pci_release_regions(dev); - os_mem_set(nvl, 0, sizeof(nv_linux_state_t)); - - return -1; - } - pci_set_master(nvl->dev); #if defined(NV_BUILD_NV_PAT_SUPPORT) if (nvos_find_pci_express_capability(nvl->dev)) @@ -3619,13 +3612,7 @@ if (nv->bar.regs.map == NULL) { nv_printf(NV_DBG_ERRORS, "NVRM: failed to map registers!!\n"); - - pci_release_regions(dev); - - /* Clear out the data */ - os_mem_set(nvl, 0, sizeof(nv_linux_state_t)); - - return -1; + goto err_zero_dev; } nv->flags |= NV_FLAG_MAP_REGS_EARLY; #endif @@ -3642,6 +3629,15 @@ num_nv_devices++; return 0; + +err_zero_dev: + os_mem_set(nvl, 0, sizeof(nv_linux_state_t)); + release_mem_region(dev->resource[0].start, + dev->resource[0].end - dev->resource[0].start + 1); + +err_disable_dev: + pci_disable_device(dev); + return -1; } int NV_API_CALL nv_no_incoherent_mappings