NetBSD Problem Report #60702

From www@netbsd.org  Wed Sep  9 12:43:52 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E1CAF1A923B
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  9 Sep 2026 12:43:52 +0000 (UTC)
Message-Id: <20260909124351.E70ED1A923C@mollari.NetBSD.org>
Date: Wed,  9 Sep 2026 12:43:51 +0000 (UTC)
From: raytran08@gmail.com
Reply-To: raytran08@gmail.com
To: gnats-bugs@NetBSD.org
Subject: mac68k: ascaudio(4) has hardcoded 368 ms playback block
X-Send-Pr-Version: www-1.0
X-From4GNATS: "raytran08@gmail.com via gnats" <gnats-admin@NetBSD.org>

>Number:         60702
>Category:       port-mac68k
>Synopsis:       mac68k: ascaudio(4) has hardcoded 368 ms playback block
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    nat
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 09 12:45:01 +0000 2026
>Closed-Date:    Thu Oct 15 15:33:14 +0000 2026
>Last-Modified:  Thu Oct 15 15:33:14 +0000 2026
>Originator:     Ray Tran
>Release:        11.0
>Organization:
Diamond Creek Digital
>Environment:
Apple Macintosh Centris 650 running NetBSD 11.0
>Description:
ascaudio_round_blocksize() returns PLAYBLKSIZE (8192 bytes) for playback
whatever size it is asked for.  At the driver's format that is a 368 ms
block.  The MI audio layer primes two blocks before it starts the
hardware (audio_pmixer_start: "Need two blocks to start normally") and
drains to a block boundary at the end, so the block size is the latency
of every sound.  On a Centris 650 the console bell rings about three
quarters of a second after the keystroke, and a 0.2 s clip takes 1.45 s
of wall time in audioplay(1).

The MI layer has a knob for this, hw.audioN.blk_ms, with a default of
10 ms.  The driver's callback overrides it, so the sysctl
exists and does nothing for playback.  The play ring in the driver takes
the block size as a parameter and does not depend on the fixed value.

I propose a change to make the callback honour the size it is asked for, rounded up to
whole FIFO halves (1024 bytes, 512 frames), with 2048 as the floor and
the old 8192 as the cap.
>How-To-Repeat:
On an AUDIO kernel, ring the console bell and listen for the delay, or
time audioplay(1) on a 0.2 s clip.  sysctl -w hw.audio0.blk_ms=10 has no effect.
>Fix:
Applies to sys/arch/mac68k/obio/ascaudio.c, on top of the patch in the
via2_noint(4) PR (ascaudio_intr_enable on A/UX-interrupt machines).

Measured on a Centris 650 (68040/25 MHz, EASC 0xbb) running NetBSD 11.0,
before and after:

	                     fixed 8192   1024 (floor tried)   2048 (floor)
	dmesg block          368 ms       46 ms                92 ms
	0.2 s clip, wall     1.45 s       0.50 s               0.56 s
	3 s clip, wall       4.38 s       3.55 s
	3 s clip, sys time   0.51 s       0.70 s

The bell is judged responsive by ear at both sizes, and two streams
mix correctly.  The extra system time at 1024 is the mixer thread
waking eight times as often, 0.2 s over a 3 s clip on this CPU.
Playback produces no via2_noint lines with both patches applied.  The
same patch applies to -current.

Applies with "patch -p1" from the top of usr/src; verified with -F0
(no fuzz) against NetBSD-current 11.99.8 (20260830003849Z) and 11.0.

--- a/sys/arch/mac68k/obio/ascaudio.c
+++ b/sys/arch/mac68k/obio/ascaudio.c
@@ -64,7 +64,22 @@
 #define	MAC68K_ASCAUDIO_LEN		0x2000

 #define BUFSIZE 			32768
-#define PLAYBLKSIZE			8192
+#define PLAYBLKUNIT			1024	/* one FIFO half: 512 frames */
+#define PLAYBLKMIN			2048	/* 92 ms */
+#define PLAYBLKSIZE			8192	/* 368 ms, the cap */
 #define RECBLKSIZE			1024

 #define ASC_VIA_CLR_INTR()     via_reg(VIA2, vIFR) = V2IF_ASC
@@ -760,10 +775,15 @@
 	sc = (ascaudio_softc_t *)opaque;
 	KASSERT(mutex_owned(&sc->sc_lock));

-	if (mode == AUMODE_PLAY)
-		return PLAYBLKSIZE;
-	else
-		return RECBLKSIZE;
+	if (mode == AUMODE_PLAY) {
+		blksize = roundup(blksize, PLAYBLKUNIT);
+		if (blksize < PLAYBLKMIN)
+			blksize = PLAYBLKMIN;
+		if (blksize > PLAYBLKSIZE)
+			blksize = PLAYBLKSIZE;
+		return blksize;
+	}
+	return RECBLKSIZE;
 }

 static void

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-mac68k-maintainer->nat
Responsible-Changed-By: nat@NetBSD.org
Responsible-Changed-When: Thu, 10 Sep 2026 11:11:43 +0000
Responsible-Changed-Why:
Take.


From: Nathanial Sloss <nathanialsloss@yahoo.com.au>
To: gnats-bugs@netbsd.org
Cc: port-mac68k-maintainer@netbsd.org,
 netbsd-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 raytran08@gmail.com
Subject: Re: port-mac68k/60702 (mac68k: ascaudio(4) has hardcoded 368 ms playback block)
Date: Tue, 15 Sep 2026 10:48:57 +1000

 Hi,

 Just wondering what command did you use to generate your patches (It wouldn't 
 apply without some manual editing)?


 Best regards and many thanks for working on this and supplying patches,

 Nat

From: Ray Tran <raytran08@gmail.com>
To: gnats-bugs@netbsd.org
Cc: nat@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: port-mac68k/60702 (mac68k: ascaudio(4) has hardcoded 368 ms
 playback block)
Date: Tue, 15 Sep 2026 22:28:46 +1000

 Hi Nat,

 Thanks for taking a look at this.

 It's a plain unified diff made with diff -u against a pristine tree,
 headers rewritten to a/=E2=80=A6/b/=E2=80=A6 so it takes -p1.
 it should apply with cd /usr/src && patch -p1.

 Regards,
 Ray Tran


 On Tue, Sep 15, 2026 at 10:50=E2=80=AFAM Nathanial Sloss via gnats
 <gnats-admin@netbsd.org> wrote:
 >
 > The following reply was made to PR port-mac68k/60702; it has been noted b=
 y GNATS.
 >
 > From: Nathanial Sloss <nathanialsloss@yahoo.com.au>
 > To: gnats-bugs@netbsd.org
 > Cc: port-mac68k-maintainer@netbsd.org,
 >  netbsd-bugs@netbsd.org,
 >  gnats-admin@netbsd.org,
 >  raytran08@gmail.com
 > Subject: Re: port-mac68k/60702 (mac68k: ascaudio(4) has hardcoded 368 ms =
 playback block)
 > Date: Tue, 15 Sep 2026 10:48:57 +1000
 >
 >  Hi,
 >
 >  Just wondering what command did you use to generate your patches (It wou=
 ldn't
 >  apply without some manual editing)?
 >
 >
 >  Best regards and many thanks for working on this and supplying patches,
 >
 >  Nat
 >

State-Changed-From-To: open->needs-pullups
State-Changed-By: nat@NetBSD.org
State-Changed-When: Wed, 16 Sep 2026 03:03:19 +0000
State-Changed-Why:
he patch and for testing.


From: Nathanial Sloss <nathanialsloss@yahoo.com.au>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 raytran08@gmail.com
Subject: Re: port-mac68k/60702 (mac68k: ascaudio(4) has hardcoded 368 ms playback block)
Date: Wed, 16 Sep 2026 15:38:33 +1000

 Thanks for clarifying.


 Best regards,

 Nat

From: Nathanial Sloss <nathanialsloss@yahoo.com.au>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 raytran08@gmail.com
Subject: Re: port-mac68k/60702 (mac68k: ascaudio(4) has hardcoded 368 ms playback block)
Date: Wed, 16 Sep 2026 15:47:13 +1000

 Opps...forgot to quote PR in the commit.

 CVS commit: src/sys/arch/mac68k/obio

     To: source-changes%NetBSD.org@localhost
         Subject: CVS commit: src/sys/arch/mac68k/obio
             From: "Nathanial Sloss" <nat%netbsd.org@localhost>
                 Date: Wed, 16 Sep 2026 02:42:09 +0000

                 Module Name:    src
                 Committed By:   nat
                 Date:           Wed Sep 16 02:42:09 UTC 2026

                 Modified Files:
                         src/sys/arch/mac68k/obio: ascaudio.c

                         Log Message:
                         Honor playback block size within resonable limits.

                         Patch and testing by Ray Tran.


                         To generate a diff of this commit:
                         cvs rdiff -u -r1.19 -r1.20 src/sys/arch/mac68k/obio/a
 scaudio.c

                         Please note that diffs are not public domain; they ar
 e subject to the
                         copyright notices on the relevant files.

State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: nat@NetBSD.org
State-Changed-When: Wed, 14 Oct 2026 06:13:43 +0000
State-Changed-Why:
Pullup -11 #529


State-Changed-From-To: pending-pullups->closed
State-Changed-By: nat@NetBSD.org
State-Changed-When: Thu, 15 Oct 2026 15:33:14 +0000
State-Changed-Why:
Pullups complete.  Thanks for the report and patch.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.