Received: from mail1.perex.cz (mail1.perex.cz [77.48.224.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C65133E5596 for ; Tue, 31 Mar 2026 09:30:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=77.48.224.245 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774949407; cv=none; b=hpGJqFIfiKwnHpSvitBhWfaSAJXktd4CWYJJ4X5WxOClTzjp0tS2WU6nF4yyI4mQYc3u2bXmgwqOcObcZO55f5szqg6KG+4biUZAnrM6n+NNi/U4ukZCI3ufJurPEAzbhSAuj36RZfJwYSlap3NkuUmhHJMi2eKD35p38D4bC4Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774949407; c=relaxed/simple; bh=R4+lCmJoBQIA60ywwKeGuJ5oHfuTZxshM//3M/jep2U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eKfJjyyAwGpFiP8yNC6JYHJlHuT+sTipMWjBFzk2TTKhLh253PALArQb/DwyZ43X0RUN71ZJm6zlhRKU+crPlI3QxK+lg4KxfN3OZ++RiOv8Xzv6duwbwPd0Ri+24YVKvPGxFXfMUXgJyVR6fjgnakiVuwCYkVzu8FR/05vwE3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=perex.cz; spf=pass smtp.mailfrom=perex.cz; dkim=pass (1024-bit key) header.d=perex.cz header.i=@perex.cz header.b=eUWtTPwE; arc=none smtp.client-ip=77.48.224.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=perex.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perex.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=perex.cz header.i=@perex.cz header.b="eUWtTPwE" Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id 197AF3A216; Tue, 31 Mar 2026 11:29:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz 197AF3A216 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1774949394; bh=vPUd703Zl3mbK75RKg48xRQejbuOSOF3Pvw8oFgaFvg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eUWtTPwE3dM8evzwlcvR4MK22nvzwvaD/lb39HQGS8wSwMNXqKMUkmPR1va1vlAbZ Xuqvd2AZ85NFstRmYHtY/W5DHE+++nh1NeCD4IeVb3UP0iu1zjAlhnQJdlWduRwVs/ bAJmDSGMHIBf15GaMVe5qipSjwv4VzEfmfXoocEI= Received: from [192.168.100.98] (unknown [192.168.100.98]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Tue, 31 Mar 2026 11:29:44 +0200 (CEST) Message-ID: <88979231-caef-4eaa-b89d-22e6973c92f9@perex.cz> Date: Tue, 31 Mar 2026 11:29:43 +0200 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: (re)use and (re)definition of snd_pcm_hw_params->fifo_size for 'jumpy DMA' To: Takashi Iwai , =?UTF-8?Q?P=C3=A9ter_Ujfalusi?= Cc: Takashi Iwai , Mark Brown , Liam Girdwood , Linux-ALSA , "linux-sound@vger.kernel.org" , Kai Vehmanen , arun@asymptotic.io, wim.taymans@gmail.com References: <87se9htms4.wl-tiwai@suse.de> <67b9f48b-1cc7-4dac-8f6a-c0cba6a84b36@linux.intel.com> <87ikadtgpe.wl-tiwai@suse.de> <878qb8tsib.wl-tiwai@suse.de> From: Jaroslav Kysela Content-Language: en-US Autocrypt: addr=perex@perex.cz; keydata= xsFNBFvNeCsBEACUu2ZgwoGXmVFGukNPWjA68/7eMWI7AvNHpekSGv3z42Iy4DGZabs2Jtvk ZeWulJmMOh9ktP9rVWYKL9H54gH5LSdxjYYTQpSCPzM37nisJaksC8XCwD4yTDR+VFCtB5z/ E7U0qujGhU5jDTne3dZpVv1QnYHlVHk4noKxLjvEQIdJWzsF6e2EMp4SLG/OXhdC9ZeNt5IU HQpcKgyIOUdq+44B4VCzAMniaNLKNAZkTQ6Hc0sz0jXdq+8ZpaoPEgLlt7IlztT/MUcH3ABD LwcFvCsuPLLmiczk6/38iIjqMtrN7/gP8nvZuvCValLyzlArtbHFH8v7qO8o/5KXX62acCZ4 aHXaUHk7ahr15VbOsaqUIFfNxpthxYFuWDu9u0lhvEef5tDWb/FX+TOa8iSLjNoe69vMCj1F srZ9x2gjbqS2NgGfpQPwwoBxG0YRf6ierZK3I6A15N0RY5/KSFCQvJOX0aW8TztisbmJvX54 GNGzWurrztj690XLp/clewmfIUS3CYFqKLErT4761BpiK5XWUB4oxYVwc+L8btk1GOCOBVsp 4xAVD2m7M+9YKitNiYM4RtFiXwqfLk1uUTEvsaFkC1vu3C9aVDn3KQrZ9M8MBh/f2c8VcKbN njxs6x6tOdF5IhUc2E+janDLPZIfWDjYJ6syHadicPiATruKvwARAQABzSBKYXJvc2xhdiBL eXNlbGEgPHBlcmV4QHBlcmV4LmN6PsLBjgQTAQgAOBYhBF7f7LZepM3UTvmsRTCsxHw/elMJ BQJbzXgrAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEDCsxHw/elMJDGAP/ReIRiRw lSzijpsGF/AslLEljncG5tvb/xHwCxK5JawIpViwwyJss06/IAvdY5vn5AdfUfCl2J+OakaR VM/hdHjCYNu4bdBYZQBmEiKsPccZG2YFDRudEmiaoaJ1e8ZsiA3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RkL62zdZyyArbVbK7uIU6utvv0eYqG9cni+o z7CAe7vMbb5KfNOAJ16+znlOFTieKGyFQBtByHkhh86BQNQn77aESJRQdXvo5YCGX3BuRUaQ zydmrgwauQTSnIhgLZPv5pphuKOmkzvlCDX+tmaCrNdNc+0geSAXNe4CqYQlSnJv6odbrQlD Qotm9QARAQABwsF2BBgBCAAgFiEEXt/stl6kzdRO+axFMKzEfD96UwkFAlvNeCsCGwwACgkQ MKzEfD96Uwlkjg/+MZVS4M/vBbIkH3byGId/MWPy13QdDzBvV0WBqfnr6n99lf7tKKp85bpB y7KRAPtXu+9WBzbbIe42sxmWJtDFIeT0HJxPn64l9a1btPnaILblE1mrfZYAxIOMk3UZA3PH uFdyhQDJbDGi3LklDhsJFTAhBZI5xMSnqhaMmWCL99OWwfyJn2omp8R+lBfAJZR31vW6wzsj ssOvKIbgBpV/o3oGyAofIXPYzhY+jhWgOYtiPw9bknu748K+kK3fk0OeEG6doO4leB7LuWig dmLZkcLlJzSE6UhEwHZ8WREOMIGJnMF51WcF0A3JUeKpYYEvSJNDEm7dRtpb0x/Y5HIfrg5/ qAKutAYPY7ClQLu5RHv5uqshiwyfGPaiE8Coyphvd5YbOlMm3mC/DbEstHG7zA89fN9gAzsJ 0TFL5lNz1s/fo+//ktlG9H28EHD8WOwkpibsngpvY+FKUGfJgIxpmdXVOkiORWQpndWyRIqw k8vz1gDNeG7HOIh46GnKIrQiUXVzAuUvM5vI9YaW3YRNTcn3pguQRt+Tl9Y6G+j+yvuLL173 m4zRUU6DOygmpQAVYSOJvKAJ07AhQGaWAAi5msM6BcTU4YGcpW7FHr6+xaFDlRHzf1lkvavX WoxP1IA1DFuBMeYMzfyi4qDWjXc+C51ZaQd39EulYMh+JVaWRoY= In-Reply-To: <878qb8tsib.wl-tiwai@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/31/26 08:36, Takashi Iwai wrote: >>> if a device allows a different queue size, it should be configurable >>> via hw_params. >> >> I'm not sure if I follow this statement. the fifo_size is a driver to >> user space information, driver fills it and user space ignores it ;) - I >> cannot find any evidence of it's use. > > If a chip has a similar constraint but the init and step sizes are > adjustable, they should be configurable via hw_params procedure -- > that's my point. > >> The init_chunk, step_chunk would be similar, the driver sets it and user >> space would use it. >> >> In SOF this will be dynamic and it will depend on the period size: >> https://github.com/thesofproject/linux/pull/5673/commits/18f3ba5e42212d77019d79ec09b7057a7703d361 > > Well, so even in your case, the driver can implement the hw_constraint > for coupling those numbers, too. Then application may choose the > init_chunk or step_chunk, which restricts the period size > automatically. If application doesn't choose those, the hw_params > engine will choose depending on the period size, and application can > see the values after hw_params call. I was more thinking about this problem and it seems that the root of this cause is that application (pipewire) is trying to bypass the period based mechanism for which we already have the handshake. It's no issue to ask for smaller periods from the app side to maintain the expected latency. It is also understandable that we need to fill at least two periods at start and keep this buffer timing (also with counting the system scheduling latencies). So, perhaps, the only flag may be added notifying that the (first) minimal period is processed immediately after start. It's also common situation for other drivers with double buffering in the driver like USB, maybe FireWire, right ? Note that this flag won't be the BATCH flag. Or we can just add a field notifying how many minimal periods are queued at start to be more universal (apparently SOF requires this, because the initial chunk of queued samples is bigger then the later chunks - so the first transfer will go over more periods). We may discuss if small periods are efficient. We have already mechanism to disable period events (SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP) and drivers don't do usually deep buffering, so they program DMA transfers with smaller (or equal) chunks than period size. It seems to me that we are trying to design another layer on top of the current just to satisfy the improper current PCM API use. And saying this, it appears that the kernel drivers (yes SOF) are trying the bypass the period constraints make it freely customized [1] instead to apply constraints based on the hardware limits including the internal maintenance (CPU <-> DSP buffering). So the issue is on both sides and the things are failing because the standard period handshake is not honored. Jaroslav [1] https://github.com/thesofproject/linux/pull/5673/changes#diff-d8bbc05d879b6eee2041d6fc0ee06f050be097ac05b12cfec9b35d89f66d3a84R79-R89 /* * When the host DMA buffer size is larger than 8ms, the firmware switches from * a constant fill mode to burst mode, keeping a 4ms threshold to trigger * transfer of approximately host DMA buffer size - 4ms after the initial burst * to fill the entire buffer. * To simplify the logic, above 20ms ALSA period size use the same size for host * DMA buffer, while if the ALSA period size is smaller than 20ms, then use a * headroom between host DMA buffer and ALSA period size. */ -- Jaroslav Kysela Linux Sound Maintainer; ALSA Project; Red Hat, Inc.