Package: nvidia-kernel-source
Version: 1.0.8178-2
Followup-For: Bug #357992
Attached is patch consolidating the differences between the
Debian nVidia source and the nVidia patch set to allow compilation under
2.6.16. Patch has been tested and works under amd64.
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (700, 'testing'), (600, 'unstable'), (500, 'stable'), (1,
'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
diff -ru usr/src/nv/conftest.sh usr/src/nv.U012206/conftest.sh
--- usr/src/nv/conftest.sh 2006-03-21 19:00:38.000000000 -0600
+++ usr/src/nv.U012206/conftest.sh 2006-03-21 19:11:46.000000000 -0600
@@ -22,8 +22,8 @@
OUTPUT=$4
CFLAGS="-D__KERNEL__ \
--nostdinc -isystem $ISYSTEM \
--Werror -Wimplicit-function-declaration"
+-DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
+-nostdinc -isystem $ISYSTEM"
if [ "$OUTPUT" != "$SOURCES" ]; then
ARCH=`uname -m | sed -e 's/i.86/i386/'`
@@ -40,7 +40,20 @@
#
echo "#include <linux/mm.h>
- int nv_remap_page_range(void) {
+ void conftest_remap_page_range(void) {
+ remap_page_range();
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ exit 1
+ fi
+
+ echo "#include <linux/mm.h>
+ int conftest_remap_page_range(void) {
pgprot_t pgprot = __pgprot(0);
return remap_page_range(NULL, 0L, 0L, 0L, pgprot);
}" > conftest$$.c
@@ -55,7 +68,7 @@
fi
echo "#include <linux/mm.h>
- int nv_remap_page_range(void) {
+ int conftest_remap_page_range(void) {
pgprot_t pgprot = __pgprot(0);
return remap_page_range(0L, 0L, 0L, pgprot);
}" > conftest$$.c
@@ -330,7 +343,7 @@
return 0;
}" > conftest$$.c
- $HOSTCC $CFLAGS -Wno-error -o conftest$$ conftest$$.c > /dev/null 2>&1
+ $HOSTCC $CFLAGS -o conftest$$ conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$ ]; then
@@ -483,8 +496,8 @@
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
#include <asm/cacheflush.h>
#endif
- int nv_change_page_attr(struct page *pp, int i, pgprot_t prot) {
- return change_page_attr(pp, i, prot);
+ void conftest_change_page_attr() {
+ change_page_attr();
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
@@ -492,9 +505,9 @@
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
- echo 1
- else
echo 0
+ else
+ echo 1
fi
;;
@@ -504,9 +517,8 @@
#
echo "#include <linux/pci.h>
- struct pci_dev*
- nv_pci_get_class(unsigned int class, struct pci_dev *from) {
- return pci_get_class(class, from);
+ void conftest_pci_get_class(void) {
+ pci_get_class();
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
@@ -514,9 +526,9 @@
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
- echo 1
- else
echo 0
+ else
+ echo 1
fi
;;
@@ -526,9 +538,8 @@
#
echo "#include <linux/mm.h>
- int nv_remap_pfn_range(void) {
- pgprot_t pgprot = __pgprot(0);
- return remap_pfn_range(NULL, 0L, 0L, 0L, pgprot);
+ void conftest_remap_pfn_range(void) {
+ remap_pfn_range();
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
@@ -536,9 +547,9 @@
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
- echo 1
- else
echo 0
+ else
+ echo 1
fi
;;
@@ -548,11 +559,11 @@
#
echo "#include <linux/sched.h>
- struct rlimit *nv_signal_struct_rlim(void) {
+ struct rlimit *conftest_signal_struct_rlim(void) {
return current->signal->rlim;
}" > conftest$$.c
- $CC $CFLAGS -Wno-error -c conftest$$.c > /dev/null 2>&1
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
@@ -572,7 +583,7 @@
echo "#include <linux/types.h>
#include <linux/agp_backend.h>
typedef struct agp_bridge_data agp_bridge_data;
- agp_bridge_data *nv_agp_backend_acquire(struct pci_dev *dev) {
+ agp_bridge_data *conftest_agp_backend_acquire(struct pci_dev *dev) {
return agp_backend_acquire(dev);
}" > conftest$$.c
@@ -594,9 +605,23 @@
#
echo "#include <linux/vmalloc.h>
- void *nv_vmap(struct page **pg, int cnt) {
+ void conftest_vmap(void) {
+ vmap();
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ exit 1
+ fi
+
+ echo "#include <linux/vmalloc.h>
+ void *conftest_vmap(struct page **pg, int cnt) {
return vmap(pg, cnt);
}" > conftest$$.c
+
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
@@ -608,9 +633,10 @@
echo "#include <linux/vmalloc.h>
#include <linux/mm.h>
- void *nv_vmap(struct page **pg, int cnt) {
+ void *conftest_vmap(struct page **pg, int cnt) {
return vmap(pg, cnt, 0, PAGE_KERNEL);
}" > conftest$$.c
+
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
@@ -618,7 +644,11 @@
rm -f conftest$$.o
echo 4
else
- exit 1 # there ain't no vmap()
+ #
+ # We couldn't determine the number of arguments expected by the
+ # vmap() function.
+ #
+ exit 1
fi
;;
@@ -629,7 +659,7 @@
#
echo "#include <linux/sched.h>
- int nv_test_sysctl_max_map_count(void) {
+ int conftest_sysctl_max_map_count(void) {
return sysctl_max_map_count;
}" > conftest$$.c
@@ -650,11 +680,11 @@
#
echo "#include <linux/pm.h>
- void nv_test_pm_message_t(pm_message_t state) {
+ void conftest_pm_message_t(pm_message_t state) {
pm_message_t *p = &state;
}" > conftest$$.c
- $CC $CFLAGS -Wno-error -c conftest$$.c > /dev/null 2>&1
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
rm -f conftest$$.c
if [ -f conftest$$.o ]; then
@@ -671,9 +701,8 @@
#
echo "#include <linux/pci.h>
- pci_power_t
- nv_pci_choose_state(struct pci_dev *dev, pm_message_t state) {
- return pci_choose_state(dev, state);
+ void conftest_pci_choose_state(void) {
+ pci_choose_state();
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
@@ -681,9 +710,9 @@
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
- echo 1
- else
echo 0
+ else
+ echo 1
fi
;;
@@ -693,9 +722,8 @@
#
echo "#include <linux/mm.h>
- int nv_vm_insert_page(void) {
- struct page *page;
- return vm_insert_page(NULL, 0L, page);
+ void conftest_vm_insert_page(void) {
+ vm_insert_page();
}" > conftest$$.c
$CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
@@ -703,9 +731,9 @@
if [ -f conftest$$.o ]; then
rm -f conftest$$.o
- echo 1
- else
echo 0
+ else
+ echo 1
fi
;;
diff -ru usr/src/nv/nv-linux.h usr/src/nv.U012206/nv-linux.h
--- usr/src/nv/nv-linux.h 2006-03-21 19:16:12.000000000 -0600
+++ usr/src/nv.U012206/nv-linux.h 2006-03-21 19:16:52.000000000 -0600
@@ -878,11 +878,7 @@
}
#endif
-#if !defined(page_to_pfn)
-#define page_to_pfn(page) ((page) - mem_map)
-#endif
-
-#if !defined(pfn_to_page)
+#if defined(KERNEL_2_4) && defined(NVCPU_X86) && !defined(pfn_to_page)
#define pfn_to_page(pfn) (mem_map + (pfn))
#endif
diff -ru usr/src/nv/nv.c usr/src/nv.U012206/nv.c
--- usr/src/nv/nv.c 2006-03-21 19:20:18.000000000 -0600
+++ usr/src/nv.U012206/nv.c 2006-03-21 19:31:02.000000000 -0600
@@ -853,7 +853,8 @@
if (!test_bit(X86_FEATURE_PAT, (volatile unsigned long *)&boot_cpu_data.x86_capability))
{
- nv_printf(NV_DBG_ERRORS, "NVRM: cpu does not support PAT, aborting..\n");
+ nv_printf(NV_DBG_ERRORS,
+ "NVRM: CPU does not support the PAT, falling back to MTRRs.\n");
return 0;
}
@@ -1411,8 +1412,11 @@
#if defined(NV_BUILD_NV_PAT_SUPPORT)
if (!nv_disable_pat)
- {
__nv_enable_pat_support();
+ else
+ {
+ nv_printf(NV_DBG_ERRORS,
+ "NVRM: builtin PAT support disabled, falling back to MTRRs.\n");
}
#endif
@@ -1893,9 +1897,6 @@
// allow setting or refusal of specific caching types
switch (cache_type)
{
- case NV_MEMORY_CACHED:
- //case NV_MEMORY_WRITEBACK:
- break;
case NV_MEMORY_UNCACHED_WEAK:
*prot = pgprot_noncached_weak(*prot);
break;
@@ -1903,19 +1904,53 @@
*prot = pgprot_noncached(*prot);
break;
case NV_MEMORY_WRITECOMBINED:
- if (nv_pat_enabled)
+ if (nv_pat_enabled &&
+ (memory_type != NV_MEMORY_TYPE_REGISTERS))
{
*prot = pgprot_writecombined(*prot);
break;
}
- /* agp allocations should be covered by an mtrr if pat isn't enabled */
+ /*
+ * If PAT support is unavailable and the memory space isn't
+ * NV_MEMORY_TYPE_AGP, we need to return an error code to
+ * the caller, but do not print a warning message.
+ *
+ * In the case of AGP memory, we will have attempted to add
+ * a WC MTRR for the AGP aperture and aborted the AGP
+ * initialization if this failed, so we can safely return
+ * success here.
+ *
+ * For frame buffer memory, callers are expected to use the
+ * UC- memory type if we report WC as unsupported, which
+ * translates to the effective memory type WC if a WC MTRR
+ * exists or else UC.
+ */
if (memory_type == NV_MEMORY_TYPE_AGP)
break;
+ return 1;
+ case NV_MEMORY_CACHED:
+ //case NV_MEMORY_WRITEBACK:
+ /*
+ * RAM is cached on Linux by default, we can assume there's
+ * nothing to be done here. This is not the case for the
+ * other memory spaces: as commented on above, we will have
+ * added a WC MTRR for the AGP aperture (or else aborted
+ * AGP initialization), and we will have made an attempt to
+ * add a WC MTRR for the frame buffer.
+ *
+ * If a WC MTRR is present, we can't satisfy the WB mapping
+ * attempt here, since the achievable effective memory
+ * types in that case are WC and UC, if not it's typically
+ * UC (MTRRdefType is UC); we could only satisfy WB mapping
+ * requests with a WB MTRR.
+ */
+ if (memory_type == NV_MEMORY_TYPE_SYSTEM)
+ break;
//case NV_MEMORY_WRITETHRU:
//case NV_MEMORY_WRITEPROTECT:
default:
nv_printf(NV_DBG_ERRORS,
- "NVRM: memory caching type 0x%x not supported for memory space %d!\n",
+ "NVRM: VM: memory type %d not supported for memory space %d!\n",
cache_type, memory_type);
return 1;
}