public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sound: oss: dmasound: kick queued output before extending tail fragment
@ 2026-04-27 22:13 Cássio Gabriel
  2026-04-29  5:53 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Cássio Gabriel @ 2026-04-27 22:13 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, Cássio Gabriel

sq_write() currently clears POST and then immediately appends
to the current rear fragment.

If the queue already contains complete fragments ahead of that
incomplete tail, playback is not kicked until the queue-full wait
path or the final sq_play() at the end of the write. That wastes
the slack those queued samples would otherwise provide while the driver
spends more time copying and translating more data into the tail fragment.

All in-tree dmasound playback backends still refuse to queue
an incomplete last fragment while !syncing, but they can start
earlier complete fragments.

Call sq_play() immediately after clearing POST and before extending
the rear fragment so already-queued complete output can start earlier.

Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
 sound/oss/dmasound/dmasound_core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index a718b75bb6a0..e80f730d0803 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -574,11 +574,6 @@ static ssize_t sq_write(struct file *file, const char __user *src, size_t uLeft,
 		uWritten = 0 ;
 	}
 
-/* FIXME: I think that this may be the wrong behaviour when we get strapped
-	for time and the cpu is close to being (or actually) behind in sending data.
-	- because we've lost the time that the N samples, already in the buffer,
-	would have given us to get here with the next lot from the user.
-*/
 	/* The interrupt doesn't start to play the last, incomplete frame.
 	 * Thus we can append to it without disabling the interrupts! (Note
 	 * also that write_sq.rear isn't affected by the interrupt.)
@@ -598,6 +593,11 @@ static ssize_t sq_write(struct file *file, const char __user *src, size_t uLeft,
 	write_sq.syncing &= ~2 ; /* take out POST status */
 	spin_unlock_irqrestore(&dmasound.lock, flags);
 
+	/* Start any already-complete fragments before we spend
+	 * more time extending the incomplete tail fragment.
+	 */
+	sq_play();
+
 	if (write_sq.count > 0 &&
 	    (bLeft = write_sq.block_size-write_sq.rear_size) > 0) {
 		dest = write_sq.buffers[write_sq.rear];

---
base-commit: 702806986e6bd2b2b37186be47aa63774bd62198
change-id: 20260427-dmasound-sq-play-445c22fd9432

Best regards,
--  
Cássio Gabriel <cassiogabrielcontato@gmail.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sound: oss: dmasound: kick queued output before extending tail fragment
  2026-04-27 22:13 [PATCH] sound: oss: dmasound: kick queued output before extending tail fragment Cássio Gabriel
@ 2026-04-29  5:53 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-04-29  5:53 UTC (permalink / raw)
  To: Cássio Gabriel
  Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel

On Tue, 28 Apr 2026 00:13:28 +0200,
Cássio Gabriel wrote:
> 
> sq_write() currently clears POST and then immediately appends
> to the current rear fragment.
> 
> If the queue already contains complete fragments ahead of that
> incomplete tail, playback is not kicked until the queue-full wait
> path or the final sq_play() at the end of the write. That wastes
> the slack those queued samples would otherwise provide while the driver
> spends more time copying and translating more data into the tail fragment.
> 
> All in-tree dmasound playback backends still refuse to queue
> an incomplete last fragment while !syncing, but they can start
> earlier complete fragments.
> 
> Call sq_play() immediately after clearing POST and before extending
> the rear fragment so already-queued complete output can start earlier.
> 
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>

Applied to for-next branch now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-29  5:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 22:13 [PATCH] sound: oss: dmasound: kick queued output before extending tail fragment Cássio Gabriel
2026-04-29  5:53 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox