Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E65C6C4338F for ; Mon, 2 Aug 2021 08:33:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A76061057 for ; Mon, 2 Aug 2021 08:33:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4A76061057 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4962A17A8; Mon, 2 Aug 2021 10:32:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4962A17A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627893223; bh=1d7uOyMLFmx54oEJZyOasHdXyvUTCmrvye6O/g20wFA=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vBjxcn8FVndZZdHqUSi9gzZp95iLH07+GLIknFQb8kmnJSwVav0kPYnuYTLSITV3m 2Z5pXIQD1xtTRhd0cGNzA4pM39Xsb1hq265SK9tSOySjHQSJBn1Tv4N9ALiX329Lkm 3NTKqM25OfyaiKqg7ojngll4bL8aXzPtwcc/tAxs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CD0F8F801F7; Mon, 2 Aug 2021 10:32:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0FE1AF8025F; Mon, 2 Aug 2021 10:32:51 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 99FACF8014D for ; Mon, 2 Aug 2021 10:32:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 99FACF8014D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="l/gBBOlj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="i3Citgw/" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 80BA31FF3D; Mon, 2 Aug 2021 08:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627893163; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GSUJi/FQgJPeBy4COebAp293EN+KA9cmLgibEFy4Zis=; b=l/gBBOljOV+EaZfBH6+BCWXCYMLq5KeF36XC1crlDq7Qyl6diNDj+I0Rx9E/olwvaYYHii yUgb8FiEBMkxvxeGtZOnRvgV3uiQVVYg9CkaCgKBrXax1rcBQUrRdMOH45yN05Xo7sJIh8 pYFi4bItLMrF7fRyHiechszW95074E4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627893163; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GSUJi/FQgJPeBy4COebAp293EN+KA9cmLgibEFy4Zis=; b=i3Citgw/nkoWVX8un7GA77wIX5NV6D22MkNb7HRzc2khhHKgpFcipIbmWptggH+6JL9/0S kOnvJ4LbcvN3ZJAA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 67D47A3B83; Mon, 2 Aug 2021 08:32:43 +0000 (UTC) Date: Mon, 02 Aug 2021 10:32:43 +0200 Message-ID: From: Takashi Iwai To: Cezary Rojewski Subject: Re: [PATCH] ASoC: intel: skylake: Drop superfluous mmap callback In-Reply-To: References: <20210728141930.17740-1-tiwai@suse.de> <0157301f-d0c1-a4a6-ad3f-4e4ad01441f6@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org, Mark Brown , Pierre-Louis Bossart X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Mon, 02 Aug 2021 10:07:12 +0200, Cezary Rojewski wrote: > > On 2021-07-30 8:20 PM, Takashi Iwai wrote: > > On Fri, 30 Jul 2021 15:59:54 +0200, > > Cezary Rojewski wrote: > > ... > > >> > >> Thanks for the input, Takashi. > >> While I welcome the change, have two quick questions: > >> > >> 1) Does this impact hw_support_mmap() and its user behavior? i.e. is > >> there some implicit behavior change that skylake-users may experience > >> along the way? > > > > hw_support_mmap() must return true for this case as long as you've set > > up the buffer in the right way (either preallocation or managed). > > hw_support_mmap() has an 'if' checking substream->ops->mmap. ASoC > framework won't assign snd_soc_pcm_component_mmap as mmap-ops in > soc_new_pcm() if component_driver didn't provided custom handler. > > This makes me believe function's behavior may change but I might as > well be missing something here. Yes, in that sense, the behavior of the driver has changed, but it's only about how the function gets called and nothing visible as the actual user-visible behavior. ASoC core leaves the PCM mmap callback empty, and ALSA core calls snd_pcm_lib_default_mmap() in the end, which is the same function that was called before the patch. > >> 2) Since snd_pcm_mmap_data() defaults to snd_pcm_lib_default_mmap() > >> why not update ops assignment - snd_pcm_set_ops() - in such a way that > >> if/else is no longer needed in the former? > > > > Simply put: when the buffer is allocated via > > snd_pcm_set_managed_buffer*(), you can omit the mmap callback. > > The only case you need the mmap callback is only when a special buffer > > is used or it needs a special way of mmap itself. > > Comment of my was more of a suggestion i.e. snd_pcm_mmap_data() has an > if-statement: > > if (substream->ops->mmap) > err = substream->ops->mmap(substream, area); > else > err = snd_pcm_lib-default_mmap(substream, area); > > I believe this could be replaced by one-liner with snd_pcm_set_ops() > modified: do the validity check + default assignment there instead. Well, at the point of snd_pcm_set_ops() called, it's not guaranteed that the driver has already set up the buffer. So we can't check at that moment, but at most, only at the point when the callback gets actually called -- and that's not easy, either. e.g. HD-audio driver calls snd_pcm_lib_default_mmap() from its own mmap callback as a fallback case where no special handling is needed. ... But, you comment made me taking a look back at the implementation of HD-audio mmap, and this brought an idea for a further cleanup; the pgprot setup could be rather in the common mmap code of WC pages, instead of the driver-specific one. Then we'll be able to get rid of the all calls of snd_pcm_lib_default_mmap(). thanks, Takashi