On Monday, 8 בDecember 2008 21:57:38 Hannu Savolainen wrote:
> Yair K. wrote:
> > On Saturday, 6 ?December 2008 22:33:19 Hannu Savolainen wrote:
> >> Yair K. wrote:
> >>> On Saturday, 6 ?December 2008 16:23:21 Hannu Savolainen wrote:
> >>>> Hi all,
> >>>>
> >>>> It appeared to be a good time to release the first OSS v4.1 build 1050
> >>>> (AKA the ID6 version). This version is now available both from the hg
> >>>> server and the stable directory of the source code download server.
> >>>
> >>> It would be nice if you can examine the attached patch. Main difference
> >>> is adding MEMLIMIT_31BITS to envy24ht and oss_sblive/Audigy cases. Some
> >>> posts at the forum suggest it may be necessary:
> >>> http://www.4front-tech.com/forum/viewtopic.php?t=2961
> >>> http://www.4front-tech.com/forum/viewtopic.php?t=2963
> >>
> >> Envy24ht supports full 32 bit PCI address range. This has been verified
> >> under Solaris/x86 where system RAM is mapped to the top of the PCI
> >> address space. Using MEMLIMIT_31BITS will break envy24ht under Sparc so
> >> it's not possible to do this change.
> >
> > How about reverting rev. 399 for osscore.c[1], since that caused all
> > these issues? See attached diff (which also adds the vmix_no_autoattach
> > parameter to FreeBSD osscore.c, allows alternative txt2man on Linux, and
> > adds overwrite checking to ossrecord).
>
> Change 399 is correct. Before it drivers that support full 32 bit PCI
> DMA failed to allocate memory if all low memory was already allocated.
>
> If some devices have problems with full 4G of RAM then those drivers
> need to be fixed instead. However it's possible that OSS uses some
> obsolete memory allocation method under Linux and this causes problems.
>

Well, per 
http://fxr.watson.org/fxr/source/arch/x86/kernel/pci-dma_64.c?v=linux-2.6#L94 
using "<=" is fine in some cases on x86_64...
How about the attached diff then? It should follow the same lines as the 
linked code. (All the reports I've seen of this issue are on x86_64 anyway).

Yours,
        Yair K.
diff -r 37882103e9d8 setup/Linux/oss/build/osscore.c
--- a/setup/Linux/oss/build/osscore.c	Sat Dec 13 17:41:47 2008 +0200
+++ b/setup/Linux/oss/build/osscore.c	Sun Dec 14 15:05:37 2008 +0200
@@ -785,31 +785,34 @@
 		   oss_native_word * phaddr)
 {
   char *start_addr, *end_addr;
-  int sz, size;
-  int flags = 0;
+  int flags = GFP_KERNEL;
 
   *phaddr = 0;
 
+#ifdef __x86_64__
+  if (memlimit <= 0x00000000ffffffffLL)
+#ifdef GFP_DMA32
+    flags |= GFP_DMA32;
+#else
+    flags |= GFP_DMA;
+#endif
+#else
   if (memlimit < 0x00000000ffffffffLL)
     flags |= GFP_DMA;
+#endif
 
-  start_addr = NULL;
-
-  for (sz = 0, size = PAGE_SIZE; size < buffsize; sz++, size <<= 1);
-
-  if (buffsize != (PAGE_SIZE * (1 << sz)))
-    {
-#if 0
-      printk
-	("Contig_malloc: Invalid size %d != %ld\n", buffsize,
-	 PAGE_SIZE * (1 << sz));
-#endif
-    }
-
-  start_addr = (char *) __get_free_pages (GFP_KERNEL | flags, sz);
+gretry:
+  start_addr = (char *) __get_free_pages (flags, get_order (buffsize));
 
   if (start_addr == NULL)
     {
+#if defined(GFP_DMA32) && defined(__x86_64__)
+      if ((flags & GFP_DMA32) && (memlimit < 0x00000000ffffffffLL))
+	{
+	  flags = (flags & ~GFP_DMA32) | GFP_DMA;
+	  goto gretry;
+	}
+#endif
       cmn_err (CE_NOTE, "Failed to allocate memory buffer of %d bytes\n",
 	       buffsize);
       return NULL;
_______________________________________________
oss-devel mailing list
oss-devel@mailman.opensound.com
http://mailman.opensound.com/mailman/listinfo/oss-devel

Reply via email to