--- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/Makefile.kbuild 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/Makefile.kbuild 2007-01-25 09:04:38.673913378 +0100 @@ -284,15 +284,12 @@ nvidiafb-sanity-check: @if ! $(CONFTEST) nvidiafb_sanity_check full_output; then exit 1; fi -xen-sanity-check: - @if ! $(CONFTEST) xen_sanity_check full_output; then exit 1; fi - # # Build the NVIDIA kernel module using Linux KBUILD. This target is used by # the "package-install" target below. # -module: cc-version-check xen-sanity-check rivafb-sanity-check nvidiafb-sanity-check +module: cc-version-check rivafb-sanity-check nvidiafb-sanity-check @if [ -z "$(PATCHLEVEL)" ]; then \ echo "failed to determine PATCHLEVEL!"; \ exit 1; \ --- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/conftest.sh 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/conftest.sh 2007-01-25 09:05:12.704040126 +0100 @@ -896,61 +896,6 @@ fi ;; - xen_sanity_check) - # - # Check if the target kernel is a Xen kernel. If so, then exit, since - # the driver doesn't currently work with Xen. - # - RET=1 - VERBOSE=$6 - FILE="linux/autoconf.h" - - if [ -f $HEADERS/$FILE -o -f $OUTPUT/include/$FILE ]; then - # - # We are looking at a configured source tree; verify - # that it's not a Xen kernel. - # - echo "#include - #ifdef CONFIG_XEN - #error CONFIG_XEN defined!! - #endif - " > conftest$$.c - - $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 - rm -f conftest$$.c - - if [ -f conftest$$.o ]; then - rm -f conftest$$.o - RET=0 - fi - else - CONFIG=$HEADERS/../.config - if [ -f $CONFIG ]; then - if [ -z "$(grep "^CONFIG_XEN=y" $CONFIG)" ]; then - RET=0 - fi - fi - fi - - if [ "$RET" != "0" ]; then - echo "The kernel you are installing for is a Xen kernel!"; - echo ""; - echo "The NVIDIA driver does not currently work on Xen kernels. If "; - echo "you are using a stock distribution kernel, please install "; - echo "a variant of this kernel without Xen support; if this is a "; - echo "custom kernel, please install a standard Linux kernel. Then "; - echo "try installing the NVIDIA kernel module again."; - echo ""; - if [ "$VERBOSE" = "full_output" ]; then - echo "*** Failed Xen sanity check. Bailing out! ***"; - echo ""; - fi - exit 1 - else - exit 0 - fi - ;; - acpi_device_ops_match) # # Determine if the acpi_device_ops data structure has --- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/nv-linux.h 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/nv-linux.h 2007-01-25 08:52:45.389335878 +0100 @@ -237,7 +237,7 @@ * tiny, and the kernel panics when it is exhausted. try to warn the user that * they need to boost the size of their pool. */ -#if defined(CONFIG_SWIOTLB) && !defined(GFP_DMA32) +#if defined(CONFIG_SWIOTLB) && !defined(GFP_DMA32) && !defined(CONFIG_XEN) #define NV_SWIOTLB 1 #endif @@ -624,7 +624,11 @@ # define NV_CLI() local_irq_disable() # define NV_SAVE_FLAGS(eflags) local_save_flags(eflags) # define NV_RESTORE_FLAGS(eflags) local_irq_restore(eflags) +#if defined(CONFIG_PREEMPT_RT) +# define NV_MAY_SLEEP() (!in_interrupt() && !in_atomic() && !in_softirq()) +#else # define NV_MAY_SLEEP() (!in_interrupt() && !in_atomic()) +#endif # define NV_MODULE_PARAMETER(x) module_param(x, int, 0) # define NV_MODULE_STRING_PARAMETER(x) module_param(x, charp, 0) @@ -769,7 +773,10 @@ #define NV_VM_INSERT_PAGE(vma, addr, page) \ vm_insert_page(vma, addr, page) #endif -#if defined(NV_REMAP_PFN_RANGE_PRESENT) +#if defined(CONFIG_XEN) +#define NV_REMAP_PAGE_RANGE(from, offset, x...) \ + io_remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x) +#elif defined(NV_REMAP_PFN_RANGE_PRESENT) #define NV_REMAP_PAGE_RANGE(from, offset, x...) \ remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x) #elif defined(NV_REMAP_PAGE_RANGE_5_PRESENT) @@ -781,6 +788,9 @@ #define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x) #endif +#if !defined(CONFIG_XEN) +#define phys_to_machine(x) x +#endif #define NV_PGD_OFFSET(address, kernel, mm) \ ({ \ --- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/nv-vm.c 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/nv-vm.c 2007-01-25 08:53:07.002686630 +0100 @@ -352,6 +352,9 @@ static void nv_flush_caches(void) { +#if defined(CONFIG_PREEMPT_RT) + if(!nv_pat_enabled) return; +#endif #if defined(KERNEL_2_4) // for 2.4 kernels, just automatically flush the caches and invalidate tlbs nv_execute_on_all_cpus(cache_flush, NULL); @@ -502,7 +505,7 @@ page_ptr->phys_addr = phys_addr; page_ptr->page_count = NV_GET_PAGE_COUNT(page_ptr); page_ptr->virt_addr = virt_addr; - page_ptr->dma_addr = page_ptr->phys_addr; + page_ptr->dma_addr = phys_to_machine(page_ptr->phys_addr); /* lock the page for dma purposes */ nv_lock_page(page_ptr); --- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/nv.c 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/nv.c 2007-01-25 08:53:07.002686630 +0100 @@ -42,8 +42,26 @@ int nv_pat_enabled = 0; +/* + * disable PAT support if XEN or PREEMPT_RT is configured in kernel + */ + +#if defined(CONFIG_XEN) || defined(CONFIG_PREEMPT_RT) +static int nv_disable_pat = 1; +#else static int nv_disable_pat = 0; +#endif + +/* + * you can re-enable PAT support for PREEMPT_RT when applying + * "nv_disable_pat=0" as kernel parameter for the sake of slightly + * better 3D performance but at the expense of higher latencies. + * if XEN is configured, then PAT support can't be enabled! + */ + +#if !defined(CONFIG_XEN) NV_MODULE_PARAMETER(nv_disable_pat); +#endif #if defined(NVCPU_X86) || defined(NVCPU_X86_64) NvU64 __nv_supported_pte_mask = ~_PAGE_NX; @@ -956,8 +974,10 @@ return; #endif +#if !defined(CONFIG_PREEMPT_RT) NV_SAVE_FLAGS(eflags); NV_CLI(); +#endif __nv_disable_caches(&cr4); NV_READ_PAT_ENTRIES(pat1, pat2); @@ -968,7 +988,9 @@ NV_WRITE_PAT_ENTRIES(pat1, pat2); __nv_enable_caches(cr4); +#if !defined(CONFIG_PREEMPT_RT) NV_RESTORE_FLAGS(eflags); +#endif } static void __nv_restore_pat_entries(void *info) @@ -982,14 +1004,18 @@ return; #endif +#if !defined(CONFIG_PREEMPT_RT) NV_SAVE_FLAGS(eflags); NV_CLI(); +#endif __nv_disable_caches(&cr4); NV_WRITE_PAT_ENTRIES(orig_pat1, orig_pat2); __nv_enable_caches(cr4); +#if !defined(CONFIG_PREEMPT_RT) NV_RESTORE_FLAGS(eflags); +#endif } #endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */ --- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/os-agp.c 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/os-agp.c 2007-01-25 08:53:07.046689379 +0100 @@ -286,7 +286,7 @@ page_ptr->phys_addr = (ptr->memory[i] & PAGE_MASK); page_ptr->virt_addr = (unsigned long) __va(page_ptr->phys_addr); - page_ptr->dma_addr = page_ptr->phys_addr; + page_ptr->dma_addr = phys_to_machine(page_ptr->phys_addr); } return RM_OK; --- NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/os-interface.c 2006-12-15 19:32:58.000000000 +0100 +++ NVIDIA-Linux-x86-1.0-9746-pkg0/usr/src/nv/os-interface.c 2007-01-25 09:01:25.909866379 +0100 @@ -533,6 +533,7 @@ MicroSeconds = MilliSeconds * 1000; tm_end.tv_usec = MicroSeconds; tm_end.tv_sec = 0; +#if !defined(CONFIG_XEN) && !defined(CONFIG_PREEMPT_RT) NV_TIMERADD(&tm_aux, &tm_end, &tm_end); /* do we have a full jiffie to wait? */ @@ -570,6 +571,7 @@ MicroSeconds = 0; } while ((jiffies = NV_USECS_TO_JIFFIES(MicroSeconds)) != 0); } +#endif if (MicroSeconds > 1000) {