Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 116085 | Differences between
and this patch

Collapse All | Expand All

(-)usr/src/nv/Makefile.kbuild (+12 lines)
Lines 186-191 Link Here
186
  ifeq ($(shell $(CONFTEST) sysctl_max_map_count), 1)
186
  ifeq ($(shell $(CONFTEST) sysctl_max_map_count), 1)
187
    EXTRA_CFLAGS += -DNV_SYSCTL_MAX_MAP_COUNT_PRESENT
187
    EXTRA_CFLAGS += -DNV_SYSCTL_MAX_MAP_COUNT_PRESENT
188
  endif
188
  endif
189
190
  ifeq ($(shell $(CONFTEST) pm_message_t), 1)
191
    EXTRA_CFLAGS += -DNV_PM_MESSAGE_T_PRESENT
192
  endif
193
194
  ifeq ($(shell $(CONFTEST) pci_choose_state), 1)
195
    EXTRA_CFLAGS += -DNV_PCI_CHOOSE_STATE_PRESENT
196
  endif
197
198
  ifeq ($(shell $(CONFTEST) vm_insert_page), 1)
199
	EXTRA_CFLAGS += -DNV_VM_INSERT_PAGE_PRESENT
200
  endif
189
endif
201
endif
190
202
191
ifeq ($(shell $(CONFTEST) remap_pfn_range), 1)
203
ifeq ($(shell $(CONFTEST) remap_pfn_range), 1)
(-)usr/src/nv/conftest.sh (-3 / +76 lines)
Lines 22-30 Link Here
22
OUTPUT=$4
22
OUTPUT=$4
23
23
24
CFLAGS="-D__KERNEL__ \
24
CFLAGS="-D__KERNEL__ \
25
-DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
25
-nostdinc -isystem $ISYSTEM \
26
-nostdinc -isystem $ISYSTEM \
26
-Werror -Wimplicit-function-declaration"
27
-Werror -Wimplicit-function-declaration"
27
28
29
touch conftest$$.c
30
$CC -Wno-attributes -c conftest$$.c > /dev/null 2>&1
31
if [ $? -eq 0 ]; then
32
    CFLAGS="$CFLAGS -Wno-attributes"
33
fi
34
rm -f conftest$$.*
35
28
if [ "$OUTPUT" != "$SOURCES" ]; then
36
if [ "$OUTPUT" != "$SOURCES" ]; then
29
    ARCH=`uname -m | sed -e 's/i.86/i386/'`
37
    ARCH=`uname -m | sed -e 's/i.86/i386/'`
30
    CFLAGS="$CFLAGS -I$OUTPUT/include2 -I$OUTPUT/include \
38
    CFLAGS="$CFLAGS -I$OUTPUT/include2 -I$OUTPUT/include \
Lines 42-48 Link Here
42
        echo "#include <linux/mm.h>
50
        echo "#include <linux/mm.h>
43
        int nv_remap_page_range(void) {
51
        int nv_remap_page_range(void) {
44
           pgprot_t pgprot = __pgprot(0);
52
           pgprot_t pgprot = __pgprot(0);
45
           remap_page_range(NULL, 0L, 0L, 0L, pgprot);
53
           return remap_page_range(NULL, 0L, 0L, 0L, pgprot);
46
        }" > conftest$$.c
54
        }" > conftest$$.c
47
55
48
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
56
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
Lines 57-63 Link Here
57
        echo "#include <linux/mm.h>
65
        echo "#include <linux/mm.h>
58
        int nv_remap_page_range(void) {
66
        int nv_remap_page_range(void) {
59
           pgprot_t pgprot = __pgprot(0);
67
           pgprot_t pgprot = __pgprot(0);
60
           remap_page_range(0L, 0L, 0L, pgprot);
68
           return remap_page_range(0L, 0L, 0L, pgprot);
61
        }" > conftest$$.c
69
        }" > conftest$$.c
62
70
63
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
71
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
Lines 528-534 Link Here
528
        echo "#include <linux/mm.h>
536
        echo "#include <linux/mm.h>
529
        int nv_remap_pfn_range(void) {
537
        int nv_remap_pfn_range(void) {
530
            pgprot_t pgprot = __pgprot(0);
538
            pgprot_t pgprot = __pgprot(0);
531
            remap_pfn_range(NULL, 0L, 0L, 0L, pgprot);
539
            return remap_pfn_range(NULL, 0L, 0L, 0L, pgprot);
532
        }" > conftest$$.c
540
        }" > conftest$$.c
533
541
534
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
542
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
Lines 644-647 Link Here
644
        fi
652
        fi
645
    ;;
653
    ;;
646
654
655
    pm_message_t)
656
        #
657
        # Does linux/pm.h declare the pm_message_t type?
658
        #
659
660
        echo "#include <linux/pm.h>
661
        void nv_test_pm_message_t(pm_message_t state) {
662
            pm_message_t *p = &state;
663
        }" > conftest$$.c
664
665
        $CC $CFLAGS -Wno-error -c conftest$$.c > /dev/null 2>&1
666
        rm -f conftest$$.c
667
668
        if [ -f conftest$$.o ]; then
669
            rm -f conftest$$.o
670
            echo 1
671
        else
672
            echo 0
673
        fi
674
    ;;
675
676
    pci_choose_state)
677
        #
678
        # Determine if pci_choose_state() is present.
679
        #
680
681
        echo "#include <linux/pci.h>
682
        pci_power_t
683
        nv_pci_choose_state(struct pci_dev *dev, pm_message_t state) {
684
            return pci_choose_state(dev, state);
685
        }" > conftest$$.c
686
687
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
688
        rm -f conftest$$.c
689
690
        if [ -f conftest$$.o ]; then
691
            rm -f conftest$$.o
692
            echo 1
693
        else
694
            echo 0
695
        fi
696
    ;;
697
698
    vm_insert_page)
699
        #
700
        # Determine if vm_insert_page() is present.
701
        #
702
703
        echo "#include <linux/mm.h>
704
        int nv_vm_insert_page(void) {
705
            struct page *page;
706
            return vm_insert_page(NULL, 0L, page);
707
        }" > conftest$$.c
708
709
        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
710
        rm -f conftest$$.c
711
712
        if [ -f conftest$$.o ]; then
713
            rm -f conftest$$.o
714
            echo 1
715
        else
716
            echo 0
717
        fi
718
    ;;
719
647
esac
720
esac
(-)usr/src/nv/nv-linux.h (-13 / +47 lines)
Lines 642-656 Link Here
642
#define NV_PRINT_AT(at)
642
#define NV_PRINT_AT(at)
643
#endif
643
#endif
644
644
645
// acpi support has been back-ported to the 2.4 kernel, but the 2.4 driver
645
/*
646
// model is not sufficient for full acpi support. it may work in some cases,
646
 * On Linux 2.6, we support both APM and ACPI power management. On Linux
647
// but not enough for us to officially support this configuration.
647
 * 2.4, we support APM, only. ACPI support has been back-ported to the
648
#if defined(CONFIG_ACPI) && defined(KERNEL_2_6)
648
 * Linux 2.4 kernel, but the Linux 2.4 driver model is not sufficient for
649
#define NV_PM_SUPPORT_ACPI
649
 * full ACPI support: it may work with some systems, but not reliably
650
 * enough for us to officially support this configuration.
651
 *
652
 * We support two Linux kernel power managment interfaces: the original
653
 * pm_register()/pm_unregister() on Linux 2.4 and the device driver model
654
 * backed PCI driver power management callbacks introduced with Linux
655
 * 2.6.
656
 *
657
 * The code below determines which interface to support on this kernel
658
 * version, if any; if built for Linux 2.6, it will also determine if the
659
 * kernel comes with ACPI or APM power management support.
660
 */
661
#if defined(KERNEL_2_6) && (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) || defined(CONFIG_ACPI))
662
#define NV_PM_SUPPORT_DEVICE_DRIVER_MODEL
663
#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
664
#define NV_PM_SUPPORT_NEW_STYLE_APM
665
#endif
650
#endif
666
#endif
651
667
652
#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
668
/*
653
#define NV_PM_SUPPORT_APM
669
 * On Linux 2.6 kernels >= 2.6.11, the PCI subsystem provides a new 
670
 * interface that allows PCI drivers to determine the correct power state
671
 * for a given system power state; our suspend/resume callbacks now use
672
 * this interface and operate on PCI power state defines.
673
 *
674
 * Define these new PCI power state #define's here for compatibility with
675
 * older Linux 2.6 kernels.
676
 */
677
#if defined(KERNEL_2_6) && !defined(PCI_D0)
678
#define PCI_D0 PM_SUSPEND_ON
679
#define PCI_D3hot PM_SUSPEND_MEM
680
#endif
681
682
#if defined(KERNEL_2_6) && !defined(NV_PM_MESSAGE_T_PRESENT)
683
typedef u32 pm_message_t;
684
#endif
685
686
#if defined(KERNEL_2_4) && (defined(CONFIG_APM) || defined(CONFIG_APM_MODULE))
687
#define NV_PM_SUPPORT_OLD_STYLE_APM
654
#endif
688
#endif
655
689
656
#ifndef minor
690
#ifndef minor
Lines 666-674 Link Here
666
#define PCI_CAP_ID_EXP 0x10
700
#define PCI_CAP_ID_EXP 0x10
667
#endif
701
#endif
668
702
703
#if defined(NV_VM_INSERT_PAGE_PRESENT)
704
#define NV_VM_INSERT_PAGE(vma, addr, page) \
705
    vm_insert_page(vma, addr, page)
706
#endif
669
#if defined(NV_REMAP_PFN_RANGE_PRESENT)
707
#if defined(NV_REMAP_PFN_RANGE_PRESENT)
670
#define NV_REMAP_PAGE_RANGE(from, offset, x...) \
708
#define NV_REMAP_PAGE_RANGE(from, offset, x...) \
671
     remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
709
    remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
672
#elif defined(NV_REMAP_PAGE_RANGE_5_PRESENT)
710
#elif defined(NV_REMAP_PAGE_RANGE_5_PRESENT)
673
#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(vma, x)
711
#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(vma, x)
674
#elif defined(NV_REMAP_PAGE_RANGE_4_PRESENT)
712
#elif defined(NV_REMAP_PAGE_RANGE_4_PRESENT)
Lines 840-850 Link Here
840
    }
878
    }
841
#endif
879
#endif
842
880
843
#if !defined(page_to_pfn)
881
#if defined(KERNEL_2_4) && defined(NVCPU_X86) && !defined(pfn_to_page)
844
#define page_to_pfn(page)  ((page) - mem_map)
845
#endif
846
847
#if !defined(pfn_to_page)
848
#define pfn_to_page(pfn) (mem_map + (pfn))
882
#define pfn_to_page(pfn) (mem_map + (pfn))
849
#endif
883
#endif
850
884
(-)usr/src/nv/nv-vm.c (-1 / +10 lines)
Lines 105-110 Link Here
105
#endif
105
#endif
106
}
106
}
107
107
108
static inline BOOL nv_page_locked(nv_pte_t *page_ptr)
109
{
110
    BOOL locked = FALSE; 
111
#if defined(PageReserved)
112
    locked = PageReserved(NV_GET_PAGE_STRUCT(page_ptr->phys_addr));
113
#endif 
114
    return locked;
115
}
116
108
#if defined(NV_SG_MAP_BUFFERS)
117
#if defined(NV_SG_MAP_BUFFERS)
109
118
110
/* track how much memory has been remapped through the iommu/swiotlb */
119
/* track how much memory has been remapped through the iommu/swiotlb */
Lines 704-710 Link Here
704
        if (!NV_ALLOC_MAPPING_CONTIG(at->flags))
713
        if (!NV_ALLOC_MAPPING_CONTIG(at->flags))
705
            nv_sg_unmap_buffer(dev, &page_ptr->sg_list, page_ptr);
714
            nv_sg_unmap_buffer(dev, &page_ptr->sg_list, page_ptr);
706
#endif
715
#endif
707
        if (!NV_ALLOC_MAPPING_CONTIG(at->flags) && !NV_ALLOC_MAPPING_VMALLOC(at->flags))
716
        if (!NV_ALLOC_MAPPING_CONTIG(at->flags) && !NV_ALLOC_MAPPING_VMALLOC(at->flags) && !nv_page_locked(page_ptr))
708
            NV_FREE_PAGES(page_ptr->virt_addr, 0);
717
            NV_FREE_PAGES(page_ptr->virt_addr, 0);
709
    }
718
    }
710
    nv_flush_caches();
719
    nv_flush_caches();
(-)usr/src/nv/nv.c (-62 / +109 lines)
Lines 29-35 Link Here
29
29
30
static nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES];
30
static nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES];
31
31
32
#if defined(NV_PM_SUPPORT_APM)
32
#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
33
static struct pm_dev *apm_nv_dev[NV_MAX_DEVICES] = { 0 };
33
static struct pm_dev *apm_nv_dev[NV_MAX_DEVICES] = { 0 };
34
#endif
34
#endif
35
35
Lines 244-251 Link Here
244
void          nv_kern_isr_bh(unsigned long);
244
void          nv_kern_isr_bh(unsigned long);
245
irqreturn_t   nv_kern_isr(int, void *, struct pt_regs *);
245
irqreturn_t   nv_kern_isr(int, void *, struct pt_regs *);
246
void          nv_kern_rc_timer(unsigned long);
246
void          nv_kern_rc_timer(unsigned long);
247
#if defined(NV_PM_SUPPORT_APM)
247
#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
248
int           nv_kern_apm_event(struct pm_dev *dev, pm_request_t rqst, void *data);
248
static int    nv_kern_apm_event(struct pm_dev *, pm_request_t, void *);
249
#endif
249
#endif
250
250
251
static int    nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
251
static int    nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
Lines 265-273 Link Here
265
unsigned int  nv_kern_ctl_poll(struct file *, poll_table *);
265
unsigned int  nv_kern_ctl_poll(struct file *, poll_table *);
266
266
267
int nv_kern_probe(struct pci_dev *, const struct pci_device_id *);
267
int nv_kern_probe(struct pci_dev *, const struct pci_device_id *);
268
#if defined(NV_PM_SUPPORT_ACPI)
268
269
int nv_kern_acpi_standby(struct pci_dev *, u32);
269
#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
270
int nv_kern_acpi_resume(struct pci_dev *);
270
static int    nv_kern_suspend(struct pci_dev *, pm_message_t);
271
static int    nv_kern_resume(struct pci_dev *);
271
#endif
272
#endif
272
273
273
/***
274
/***
Lines 292-300 Link Here
292
    .name     = "nvidia",
293
    .name     = "nvidia",
293
    .id_table = nv_pci_table,
294
    .id_table = nv_pci_table,
294
    .probe    = nv_kern_probe,
295
    .probe    = nv_kern_probe,
295
#if defined(NV_PM_SUPPORT_ACPI)
296
#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
296
    .suspend  = nv_kern_acpi_standby,
297
    .suspend  = nv_kern_suspend,
297
    .resume   = nv_kern_acpi_resume,
298
    .resume   = nv_kern_resume,
298
#endif
299
#endif
299
};
300
};
300
301
Lines 852-858 Link Here
852
853
853
    if (!test_bit(X86_FEATURE_PAT, (volatile unsigned long *)&boot_cpu_data.x86_capability))
854
    if (!test_bit(X86_FEATURE_PAT, (volatile unsigned long *)&boot_cpu_data.x86_capability))
854
    {
855
    {
855
        nv_printf(NV_DBG_ERRORS, "NVRM: cpu does not support PAT, aborting..\n");
856
        nv_printf(NV_DBG_ERRORS,
857
            "NVRM: CPU does not support the PAT, falling back to MTRRs.\n");
856
        return 0;
858
        return 0;
857
    }
859
    }
858
860
Lines 1084-1092 Link Here
1084
1086
1085
        // broken kernels may get confused after splitting the page and
1087
        // broken kernels may get confused after splitting the page and
1086
        // restore the page before returning to us. detect that case.
1088
        // restore the page before returning to us. detect that case.
1087
        if ( (pte_val(*kpte) == kpte_val) &&
1089
        if (((pte_val(*kpte) & ~_PAGE_NX) == kpte_val) &&
1088
             (pte_val(*kpte) & _PAGE_PSE))
1090
            (pte_val(*kpte) & _PAGE_PSE))
1089
        {
1091
        {
1092
            if ((pte_val(*kpte) & _PAGE_NX) &&
1093
                    (__nv_supported_pte_mask & _PAGE_NX) == 0)
1094
                clear_bit(_PAGE_BIT_NX, kpte);
1090
            spin_unlock(&init_mm.page_table_lock);
1095
            spin_unlock(&init_mm.page_table_lock);
1091
            // don't change the page back, as it's already been reverted
1096
            // don't change the page back, as it's already been reverted
1092
            put_page(kpte_page);
1097
            put_page(kpte_page);
Lines 1299-1305 Link Here
1299
        nv_lock_init_locks(nv_ctl);
1304
        nv_lock_init_locks(nv_ctl);
1300
    }
1305
    }
1301
1306
1302
#if defined(NV_PM_SUPPORT_APM)
1307
#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
1303
    for (i = 0; i < num_nv_devices; i++)
1308
    for (i = 0; i < num_nv_devices; i++)
1304
    {
1309
    {
1305
        apm_nv_dev[i] = pm_register(PM_PCI_DEV, PM_SYS_VGA, nv_kern_apm_event);
1310
        apm_nv_dev[i] = pm_register(PM_PCI_DEV, PM_SYS_VGA, nv_kern_apm_event);
Lines 1407-1414 Link Here
1407
1412
1408
#if defined(NV_BUILD_NV_PAT_SUPPORT)
1413
#if defined(NV_BUILD_NV_PAT_SUPPORT)
1409
    if (!nv_disable_pat)
1414
    if (!nv_disable_pat)
1410
    {
1411
        __nv_enable_pat_support();
1415
        __nv_enable_pat_support();
1416
    else
1417
    {
1418
        nv_printf(NV_DBG_ERRORS,
1419
            "NVRM: builtin PAT support disabled, falling back to MTRRs.\n");
1412
    }
1420
    }
1413
#endif
1421
#endif
1414
1422
Lines 1418-1424 Link Here
1418
    if (nv_pte_t_cache != NULL)
1426
    if (nv_pte_t_cache != NULL)
1419
        NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
1427
        NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
1420
1428
1421
#if defined(NV_PM_SUPPORT_APM)
1429
#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
1422
    for (i = 0; i < num_nv_devices; i++)
1430
    for (i = 0; i < num_nv_devices; i++)
1423
        if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
1431
        if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
1424
#endif
1432
#endif
Lines 1473-1482 Link Here
1473
    inter_module_unregister("nv_linux_devices");
1481
    inter_module_unregister("nv_linux_devices");
1474
#endif
1482
#endif
1475
1483
1476
#if defined(NV_PM_SUPPORT_APM)
1484
#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
1477
    for (i = 0; i < num_nv_devices; i++)
1485
    for (i = 0; i < num_nv_devices; i++)
1478
    {
1486
    {
1479
        pm_unregister(apm_nv_dev[i]);
1487
        if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
1480
    }
1488
    }
1481
#endif
1489
#endif
1482
1490
Lines 1889-1897 Link Here
1889
    // allow setting or refusal of specific caching types
1897
    // allow setting or refusal of specific caching types
1890
    switch (cache_type)
1898
    switch (cache_type)
1891
    {
1899
    {
1892
        case NV_MEMORY_CACHED:
1893
        //case NV_MEMORY_WRITEBACK:
1894
            break;
1895
        case NV_MEMORY_UNCACHED_WEAK:
1900
        case NV_MEMORY_UNCACHED_WEAK:
1896
            *prot = pgprot_noncached_weak(*prot);
1901
            *prot = pgprot_noncached_weak(*prot);
1897
            break;
1902
            break;
Lines 1899-1917 Link Here
1899
            *prot = pgprot_noncached(*prot);
1904
            *prot = pgprot_noncached(*prot);
1900
            break;
1905
            break;
1901
        case NV_MEMORY_WRITECOMBINED:
1906
        case NV_MEMORY_WRITECOMBINED:
1902
            if (nv_pat_enabled)
1907
            if (nv_pat_enabled &&
1908
                (memory_type != NV_MEMORY_TYPE_REGISTERS))
1903
            {
1909
            {
1904
                *prot = pgprot_writecombined(*prot);
1910
                *prot = pgprot_writecombined(*prot);
1905
                break;
1911
                break;
1906
            }
1912
            }
1907
            /* agp allocations should be covered by an mtrr if pat isn't enabled */
1913
            /*
1914
             * If PAT support is unavailable and the memory space isn't
1915
             * NV_MEMORY_TYPE_AGP, we need to return an error code to
1916
             * the caller, but do not print a warning message.
1917
             *
1918
             * In the case of AGP memory, we will have attempted to add
1919
             * a WC MTRR for the AGP aperture and aborted the AGP
1920
             * initialization if this failed, so we can safely return
1921
             * success here.
1922
             *
1923
             * For frame buffer memory, callers are expected to use the
1924
             * UC- memory type if we report WC as unsupported, which
1925
             * translates to the effective memory type WC if a WC MTRR
1926
             * exists or else UC.
1927
             */
1908
            if (memory_type == NV_MEMORY_TYPE_AGP)
1928
            if (memory_type == NV_MEMORY_TYPE_AGP)
1909
                break;
1929
                break;
1930
            return 1;
1931
        case NV_MEMORY_CACHED:
1932
        //case NV_MEMORY_WRITEBACK:
1933
            /*
1934
             * RAM is cached on Linux by default, we can assume there's
1935
             * nothing to be done here. This is not the case for the
1936
             * other memory spaces: as commented on above, we will have
1937
             * added a WC MTRR for the AGP aperture (or else aborted
1938
             * AGP initialization), and we will have made an attempt to
1939
             * add a WC MTRR for the frame buffer.
1940
             *
1941
             * If a WC MTRR is present, we can't satisfy the WB mapping
1942
             * attempt here, since the achievable effective memory
1943
             * types in that case are WC and UC, if not it's typically
1944
             * UC (MTRRdefType is UC); we could only satisfy WB mapping
1945
             * requests with a WB MTRR.
1946
             */
1947
            if (memory_type == NV_MEMORY_TYPE_SYSTEM)
1948
                break;
1910
        //case NV_MEMORY_WRITETHRU:
1949
        //case NV_MEMORY_WRITETHRU:
1911
        //case NV_MEMORY_WRITEPROTECT:
1950
        //case NV_MEMORY_WRITEPROTECT:
1912
        default:
1951
        default:
1913
            nv_printf(NV_DBG_ERRORS,
1952
            nv_printf(NV_DBG_ERRORS,
1914
                "NVRM: memory caching type 0x%x not supported for memory space %d!\n",
1953
                "NVRM: VM: memory type %d not supported for memory space %d!\n",
1915
                cache_type, memory_type);
1954
                cache_type, memory_type);
1916
            return 1;
1955
            return 1;
1917
    }
1956
    }
Lines 2118-2125 Link Here
2118
        for (j = i; j < (i + pages); j++)
2157
        for (j = i; j < (i + pages); j++)
2119
        {
2158
        {
2120
            nv_verify_page_mappings(at->page_table[j], NV_ALLOC_MAPPING(at->flags));
2159
            nv_verify_page_mappings(at->page_table[j], NV_ALLOC_MAPPING(at->flags));
2160
#if defined(NV_VM_INSERT_PAGE_PRESENT)
2161
            if (NV_VM_INSERT_PAGE(vma, start,
2162
                    NV_GET_PAGE_STRUCT(at->page_table[j]->phys_addr)))
2163
#else
2121
            if (NV_REMAP_PAGE_RANGE(start, at->page_table[j]->phys_addr,
2164
            if (NV_REMAP_PAGE_RANGE(start, at->page_table[j]->phys_addr,
2122
                    PAGE_SIZE, vma->vm_page_prot))
2165
                    PAGE_SIZE, vma->vm_page_prot))
2166
#endif
2123
            {
2167
            {
2124
                NV_ATOMIC_DEC(at->usage_count);
2168
                NV_ATOMIC_DEC(at->usage_count);
2125
                return -EAGAIN;
2169
                return -EAGAIN;
Lines 2429-2437 Link Here
2429
    mod_timer(&nvl->rc_timer, jiffies + HZ);  /* set another timeout in 1 second */
2473
    mod_timer(&nvl->rc_timer, jiffies + HZ);  /* set another timeout in 1 second */
2430
}
2474
}
2431
2475
2432
#if defined(NV_PM_SUPPORT_APM)
2476
#if defined(NV_PM_SUPPORT_OLD_STYLE_APM)
2433
/* kernel calls us with a power management event */
2477
/* kernel calls us with a power management event */
2434
int
2478
static int
2435
nv_kern_apm_event(
2479
nv_kern_apm_event(
2436
    struct pm_dev *dev,
2480
    struct pm_dev *dev,
2437
    pm_request_t rqst,
2481
    pm_request_t rqst,
Lines 2466-2472 Link Here
2466
2510
2467
    switch (rqst)
2511
    switch (rqst)
2468
    {
2512
    {
2469
#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
2470
        case PM_RESUME:
2513
        case PM_RESUME:
2471
            nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
2514
            nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
2472
            status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
2515
            status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
Lines 2476-2490 Link Here
2476
            nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
2519
            nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
2477
            status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
2520
            status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
2478
            break;
2521
            break;
2479
#endif
2480
2522
2481
#if defined(KERNEL_2_4)
2482
        // 2.4 kernels sent a PM_SAVE_STATE request when powering down via
2523
        // 2.4 kernels sent a PM_SAVE_STATE request when powering down via
2483
        // ACPI. just ignore it and return success so the power down works
2524
        // ACPI. just ignore it and return success so the power down works
2484
        case PM_SAVE_STATE:
2525
        case PM_SAVE_STATE:
2485
            status = RM_OK;
2526
            status = RM_OK;
2486
            break;
2527
            break;
2487
#endif
2488
2528
2489
        default:
2529
        default:
2490
            nv_printf(NV_DBG_WARNINGS, "NVRM: APM: unsupported event: %d\n", rqst);
2530
            nv_printf(NV_DBG_WARNINGS, "NVRM: APM: unsupported event: %d\n", rqst);
Lines 2496-2502 Link Here
2496
2536
2497
    return status;
2537
    return status;
2498
}
2538
}
2499
#endif
2539
#endif /* defined(NV_PM_SUPPORT_OLD_STYLE_APM) */
2500
2540
2501
/*
2541
/*
2502
** nv_kern_ctl_open
2542
** nv_kern_ctl_open
Lines 3739-3744 Link Here
3739
    nvl = &nv_linux_devices[num_nv_devices];
3779
    nvl = &nv_linux_devices[num_nv_devices];
3740
    nv  = NV_STATE_PTR(nvl);
3780
    nv  = NV_STATE_PTR(nvl);
3741
3781
3782
    pci_set_drvdata(dev, (void *)nvl);
3742
    nvl->dev          = dev;
3783
    nvl->dev          = dev;
3743
    nv->vendor_id     = dev->vendor;
3784
    nv->vendor_id     = dev->vendor;
3744
    nv->device_id     = dev->device;
3785
    nv->device_id     = dev->device;
Lines 3816-3826 Link Here
3816
#endif
3857
#endif
3817
}
3858
}
3818
3859
3819
#if defined(NV_PM_SUPPORT_ACPI)
3860
#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL)
3820
3861
3821
int
3862
static int
3822
nv_acpi_event
3863
nv_power_management(
3823
(
3824
    struct pci_dev *dev, 
3864
    struct pci_dev *dev, 
3825
    u32 state
3865
    u32 state
3826
)
3866
)
Lines 3828-3897 Link Here
3828
    nv_state_t *nv;
3868
    nv_state_t *nv;
3829
    nv_linux_state_t *lnv = NULL;
3869
    nv_linux_state_t *lnv = NULL;
3830
    int status = RM_OK;
3870
    int status = RM_OK;
3831
    U032 i;
3832
3871
3833
    nv_printf(NV_DBG_INFO, "NVRM: nv_acpi_event: %d\n", state);
3872
    nv_printf(NV_DBG_INFO, "NVRM: nv_power_management: %d\n", state);
3834
3873
    lnv = pci_get_drvdata(dev);
3835
    for (i = 0; i < num_nv_devices; i++)
3836
    {
3837
        if (nv_linux_devices[i].dev == dev)
3838
        {
3839
            lnv = &nv_linux_devices[i];
3840
            break;
3841
        }
3842
    }
3843
3874
3844
    if ((!lnv) || (lnv->dev != dev))
3875
    if ((!lnv) || (lnv->dev != dev))
3845
    {
3876
    {
3846
        nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: invalid device!\n");
3877
        nv_printf(NV_DBG_WARNINGS, "NVRM: PM: invalid device!\n");
3847
        return -1;
3878
        return -1;
3848
    }
3879
    }
3849
3880
3850
    nv = NV_STATE_PTR(lnv);
3881
    nv = NV_STATE_PTR(lnv);
3882
    nv_verify_pci_config(NV_STATE_PTR(lnv), TRUE);
3851
3883
3852
    switch (state)
3884
    switch (state)
3853
    {
3885
    {
3854
        case PM_SUSPEND_MEM:
3886
#if defined(NV_PM_SUPPORT_NEW_STYLE_APM)
3887
        case PCI_D3hot:
3888
            nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
3889
            status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
3890
            break;
3891
3892
        case PCI_D0:
3893
            nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
3894
            status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
3895
            break;
3896
#else
3897
        case PCI_D3hot:
3855
            nv_printf(NV_DBG_INFO, "NVRM: ACPI: received suspend event\n");
3898
            nv_printf(NV_DBG_INFO, "NVRM: ACPI: received suspend event\n");
3856
            status = rm_power_management(nv, 0, NV_PM_ACPI_STANDBY);
3899
            status = rm_power_management(nv, 0, NV_PM_ACPI_STANDBY);
3857
            break;
3900
            break;
3858
3901
3859
        case PM_SUSPEND_ON:
3902
        case PCI_D0:
3860
            nv_printf(NV_DBG_INFO, "NVRM: ACPI: received resume event\n");
3903
            nv_printf(NV_DBG_INFO, "NVRM: ACPI: received resume event\n");
3861
            status = rm_power_management(nv, 0, NV_PM_ACPI_RESUME);
3904
            status = rm_power_management(nv, 0, NV_PM_ACPI_RESUME);
3862
            break;
3905
            break;
3863
3906
#endif
3864
        default:
3907
        default:
3865
            nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: unsupported event: %d\n", state);
3908
            nv_printf(NV_DBG_WARNINGS, "NVRM: PM: unsupported event: %d\n", state);
3866
            return -1;
3909
            return -1;
3867
    }
3910
    }
3868
3911
3869
    if (status != RM_OK)
3912
    if (status != RM_OK)
3870
        nv_printf(NV_DBG_ERRORS, "NVRM: ACPI: failed event: %d\n", state);
3913
        nv_printf(NV_DBG_ERRORS, "NVRM: PM: failed event: %d\n", state);
3871
3914
3872
    return status;
3915
    return status;
3873
}
3916
}
3874
3917
3875
int
3918
static int nv_kern_suspend(
3876
nv_kern_acpi_standby
3919
    struct pci_dev *dev,
3877
(
3920
    pm_message_t state
3878
    struct pci_dev *dev, 
3879
    u32 state
3880
)
3921
)
3881
{
3922
{
3882
    return nv_acpi_event(dev, state);
3923
    int power_state = -1;
3924
3925
#if !defined(NV_PM_MESSAGE_T_PRESENT)
3926
    power_state = state;
3927
#elif defined(NV_PCI_CHOOSE_STATE_PRESENT)
3928
    power_state = pci_choose_state(dev, state);
3929
#endif
3930
3931
    return nv_power_management(dev, power_state);
3883
}
3932
}
3884
3933
3885
int
3934
static int nv_kern_resume(
3886
nv_kern_acpi_resume
3887
(
3888
    struct pci_dev *dev
3935
    struct pci_dev *dev
3889
)
3936
)
3890
{
3937
{
3891
    return nv_acpi_event(dev, PM_SUSPEND_ON);
3938
    return nv_power_management(dev, PCI_D0);
3892
}
3939
}
3893
3940
3894
#endif
3941
#endif /* defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) */
3895
3942
3896
void* NV_API_CALL nv_get_adapter_state(
3943
void* NV_API_CALL nv_get_adapter_state(
3897
    U016 bus,
3944
    U016 bus,

Return to bug 116085