[PATCH] fix buffering in sys/dev/sound/pci/via82c686.c

From: Bruce M Simpson <bms_at_spc.org>
Date: Sun, 4 Jul 2004 19:11:25 +0100
A friend of mine has sent this my way, perhaps someone from sound can
have a look?

Regards,
BMS

attached mail follows:


In message <20040610114914.GN4623_at_empiric.dek.spc.org>, Bruce M Simpson wrote:

Hi dude

I have a patch for you:

rufus# diff -u via82c686.c.orig via82c686.c
--- via82c686.c.orig    Thu Jul  1 12:28:25 2004
+++ via82c686.c Thu Jul  1 12:28:43 2004
_at__at_ -41,7 +41,7 _at__at_
 #define SEGS_PER_CHAN  (NSEGS/2)
 
 #define TIMEOUT        50
-#define        VIA_DEFAULT_BUFSZ       0x1000
+#define        VIA_DEFAULT_BUFSZ       0x8000
 
 #undef DEB
 #define DEB(x)
_at__at_ -569,7 +569,7 _at__at_
                goto bad;
                        }
 
-       if (bus_dmamem_alloc(via->sgd_dmat, (void **)&via->sgd_table, BUS_DMA_NOWAIT, &via->sgd_dmamap) == -1)
+       if (bus_dmamem_alloc(via->sgd_dmat, (void **)&via->sgd_table, BUS_DMA_NOWAIT, &via->sgd_dmamap))
            goto bad;
        if (bus_dmamap_load(via->sgd_dmat, via->sgd_dmamap, via->sgd_table, NSEGS * sizeof(struct via_dma_op), dma_cb, via, 0))
            goto bad;
                    

The change of VIA_DEFAULT_BUFSZ to 0x8000 is personal because I don't care
about latency and the default value of 0x1000 is unusable on anything unless
it happens to have a 100GHZ processort, and mine is onyl 800MHZ.

This has annoyed me for ages, how about some kind of sysctl for sound buffers?

Anyway, the other update is critical (bus_dmamem_alloc), because the driver doesn't
correctly detect an invalid buffer allocation and will load, playing a sound will then
results in some form of kernel corruption. (ie bus_dmamem_alloc returns ENOMEM (12) not
-1 for error).

L8r

darron
Received on Sun Jul 04 2004 - 16:11:30 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:00 UTC