From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [RESEND][PATCH v4 1/3] ALSA: core: let low-level driver or userspace disable rewinds Date: Sun, 25 Mar 2018 16:58:58 +0200 Message-ID: References: <1521561668-28613-1-git-send-email-sriramx.periyasamy@intel.com> <1521561668-28613-2-git-send-email-sriramx.periyasamy@intel.com> <20180325104643.GA13721@intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 054E9266AE4 for ; Sun, 25 Mar 2018 16:59:01 +0200 (CEST) In-Reply-To: <20180325104643.GA13721@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Sriram Periyasamy Cc: ALSA ML , Vinod Koul , Pierre-Louis Bossart , Ramesh Babu , Takashi Sakamoto , Liam Girdwood , Patches Audio , Mark Brown , "Subhransu S . Prusty" List-Id: alsa-devel@alsa-project.org On Sun, 25 Mar 2018 12:46:43 +0200, Sriram Periyasamy wrote: > > On Tue, Mar 20, 2018 at 05:17:35PM +0100, Takashi Iwai wrote: > > On Tue, 20 Mar 2018 17:01:06 +0100, > > Sriram Periyasamy wrote: > > > > > > From: Pierre-Louis Bossart > > > > > > Add new hw_params flag to explicitly tell driver that rewinds will never > > > be used. This can be used by low-level driver to optimize DMA operations > > > and reduce power consumption. Use this flag only when data written in > > > ring buffer will never be invalidated, e.g. any update of appl_ptr is > > > final. > > > > > > Note that the update of appl_ptr include both a read/write data > > > operation as well as snd_pcm_forward() whose behavior is not modified. > > > > > > Signed-off-by: Pierre-Louis Bossart > > > Signed-off-by: Ramesh Babu > > > Signed-off-by: Subhransu S. Prusty > > > Signed-off-by: Sriram Periyasamy > > > > Well, I'm still not convinced with this flag. > > > > First off, does it really need to be per PCM stream? The introducing > > Flag per PCM stream helps where each stream in given system may have > different requirement such as low power or low latency based on the > use case. For example in case of low power stream, driver can perform > required optimizations at hardware level based on the no_rewind flag. Yes, but does it really need to be PCM stream, i.e. per application? Certainly the system will be using some sound backend (like PA). In which scenario can such behavior change -- some application uses a different backend on a phone or a tablet? > > something to hw_parms implies that it varies per application. But I > > can't imagine that a system requires different behavior per stream > > regarding such a thing. > > > > Second, the driver can implement a check in PCM ack callback to > > prevent the rewind, too. Then there is no need to touch the PCM > > core. > > > > As per the previous discussion at [1], > > [1] > https://patchwork.kernel.org/patch/9795233/ > > from Pierre, > > "The application (which is in most cases an audio server) *knows* if it > requires rewinds or not. It's part of its design, with rewinds typically > disabled if period interrupts are required. It's been that way for a > number of years now. The use of rewinds is typically associated with the > combination of a large buffer and no interrupts (having either of the > two would not require rewinds). > > So the idea is that the application makes a statement that rewinds will > not be used, and the low-level driver makes use of the information to > enable whatever optimizations are available at the hardware level. > > Exposing more information to userspace would quickly lead to a confusing > decision-making and would require more than just a flag." And, requiring *that* information is already confusing, IMO. Think from the application writer POV: what is the relation between the power-saving and no_rewind behavior in application level at all? If you have no idea about the hardware details, they are totally irrelevant. Or, think like this way: imagine a hardware that requires a different constraint, e.g. the power-of-two buffer size, for power-efficient operation. What would you do? Adding a new power_of_two bit flag into hw_params? Likely not. In such a case, I would expect some operation mode switch (e.g. power-saving vs low latency or whatever) instead of a very specific hw_parmas flag. It might be a module option, via ALSA control, or something else. But it's clearer for which purpose it's present, at least, and it can be implemented well without changing the existing API. thanks, Takashi