From: Takashi Iwai Subject: Re: [PATCH 3/3] ALSA: pcm: conditionally avoid mmap of control data Date: Tue, 16 May 2017 08:18:06 +0200 Message-ID: References: <1494896518-23399-1-git-send-email-subhransu.s.prusty@intel.com> <1494896518-23399-4-git-send-email-subhransu.s.prusty@intel.com> <50e717b2-2a88-08d7-7560-e80a7c43540c@sakamocchi.jp> 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 mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 0D4AB267480 for ; Tue, 16 May 2017 08:18:09 +0200 (CEST) In-Reply-To: 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: Takashi Sakamoto Cc: alsa-devel@alsa-project.org, patches.audio@intel.com, lgirdwood@gmail.com, Ramesh Babu , Pierre-Louis Bossart , broonie@kernel.org, Jaikrishna Nemallapudi , "Subhransu S. Prusty" List-Id: alsa-devel@alsa-project.org On Tue, 16 May 2017 07:57:30 +0200, Takashi Sakamoto wrote: > > On May 16 2017 14:46, Takashi Iwai wrote: > > In this case, the problem is that the mmap control allows the appl_ptr > > being changed silently without interaction with the driver. If the > > driver requires some explicit action for changing the appl_ptr, it > > won't work. > > I think 'struct snd_pcm_ops.pointer' is available for this purpose, too. > > static snd_pcm_sframes_t snd_pcm_playback_rewind(...) > { > ... > hw_avail = snd_pcm_playback_hw_avail(runtime); > (->struct snd_pcm_ops.pointer()) > ... > (rewind PCM frames) > ... > + substream->ops->pointer(...); > (->struct snd_pcm_ops.pointer()) > ... > } > > If drivers need to handle event to update the appl_ptr, it records > value of the appl_ptr, then compare it to current value to get the > updates. IIRC, the problem isn't about the forward / rewind but about the normal data transfer. In mmap mode, we transfer data on the mmap buffer, and update appl_ptr via mmap control. Both are done without notification to the driver (which is intentional for avoiding the context switching). So we want to disable this optimization and always notify to the driver. Disabling mmap status/control is the straight hack as it falls back to ioctl and then the driver can know the change. Takashi