Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Jul 2004 19:11:25 +0100
From:      Bruce M Simpson <bms@spc.org>
To:        freebsd-current@FreeBSD.org
Subject:   [PATCH] fix buffering in sys/dev/sound/pci/via82c686.c
Message-ID:  <20040704181125.GF11170@empiric.dek.spc.org>

next in thread | raw e-mail | index | archive | help

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

A friend of mine has sent this my way, perhaps someone from sound can
have a look?

Regards,
BMS

--XsQoSWH+UP9D9v3l
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <darron@kewl.org>
X-Original-To: bms@spc.org
Delivered-To: bms@spc.org
Received: from localhost (localhost [127.0.0.1])
	by arginine.spc.org (Postfix) with ESMTP id 952D265219
	for <bms@spc.org>; Thu,  1 Jul 2004 12:36:27 +0100 (BST)
Received: from arginine.spc.org ([127.0.0.1])
 by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024)
 with LMTP id 44163-05-6 for <bms@spc.org>;
 Thu,  1 Jul 2004 12:36:27 +0100 (BST)
Received: from bogus.kewl.org (bogus.kewl.org [213.253.1.247])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by arginine.spc.org (Postfix) with ESMTP id E135C651FA
	for <bms@spc.org>; Thu,  1 Jul 2004 12:36:26 +0100 (BST)
Received: from localhost ([127.0.0.1] helo=bogus.kewl.org)
	by bogus.kewl.org with esmtp (Exim 4.34)
	id 1BfzrZ-000Fjs-FT
	for bms@spc.org; Thu, 01 Jul 2004 12:36:21 +0100
From: Darron Broad <darron@kewl.org>
X-Mailer: nmh-1.04
To: Bruce M Simpson <bms@spc.org>
Subject: Re: Network diagrams ready 
In-reply-to: <20040610114914.GN4623@empiric.dek.spc.org> 
References: <20040610114914.GN4623@empiric.dek.spc.org>
Comments: In-reply-to Bruce M Simpson <bms@spc.org>
   message dated "Thu, 10 Jun 2004 12:49:14 +0100."
Date: Thu, 01 Jul 2004 12:36:21 +0100
Message-ID: <60503.1088681781@bogus.kewl.org>
X-Spam-Status: No, hits=-1.9 required=5.0
	tests=EMAIL_ATTRIBUTION,IN_REP_TO,J_CHICKENPOX_66,
	      PATCH_UNIFIED_DIFF,REFERENCES,REPLY_WITH_QUOTES
	version=2.55
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
X-Spam-Report: This mail is probably spam.  The original message has been
	attachedunwanted
	mail in future.  See http://spamassassin.org/tag/ for more details.
	<20040610114914.GN4623@empiric.dek.spc.org>,
	Bruce M Simpson wrote: Hi dude I have a patch for you: [...] 
	Content analysis details:   (-1.90 points, 5 required)
	IN_REP_TO          (-0.5 points) Has a In-Reply-To headerheader
	{6}Letteremail attributionpatch from diff -u
	REPLY_WITH_QUOTES  (-0.5 points) Reply with quoted text

In message <20040610114914.GN4623@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
@@ -41,7 +41,7 @@
 #define SEGS_PER_CHAN  (NSEGS/2)
 
 #define TIMEOUT        50
-#define        VIA_DEFAULT_BUFSZ       0x1000
+#define        VIA_DEFAULT_BUFSZ       0x8000
 
 #undef DEB
 #define DEB(x)
@@ -569,7 +569,7 @@
                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


--XsQoSWH+UP9D9v3l--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040704181125.GF11170>