Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp941952pxb; Wed, 3 Mar 2021 21:56:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWGyEDqU49M/EtT+A+jre8TWTpDNeUgRQEYWLf854vrrSM4RCH12r8FjXJMGjHUXYNszgH X-Received: by 2002:a50:aac8:: with SMTP id r8mr2523615edc.9.1614837390605; Wed, 03 Mar 2021 21:56:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614837390; cv=none; d=google.com; s=arc-20160816; b=ha7NkzMM4iRmF7YgWTqn7qj5/CdFPSkjlZEynXiWt3XIrF11prUYTjGG0ivTdpW41X OnfOw+MdU7ZuDqeU0SNPYvoQmjNBG2QzPV522kT0SAGe2Qd334efPd0hdOkMpP3me8tO jtw/5FFIXxs78lHKPJ4Abk0aPADLFCJeBr+6NT5m1f5obJ/Pj3PWXK17C5EoU3MGCTQM M6nFDeLNxuGf1cl+DkIedfhdGjZArOlLB/UjqYbqgtKoKzelDV2lRCiI5q0F6R/6OMge DhFtU1aZY0/W9Ivl0u+ptAk3Cs/ugeaHqUI6GkqPHdWnzCilSkZN7fvng9BPkgL67+DU zFWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=4sN57iPudVQF4cLcjMyCUFlS4xPHYIeQCtlSlgPLbjw=; b=KO4M5MxfUtsFHEOEZRj03sTtJf1tHGN0jFA0HLuYqHWIdNChIZ474IvCrfNy6ay+XS OK3BhHSJ40VexPlI9ly0pp6dCOFmRXswrwBsGWnDxAqFyYPrHMSOuYbYSomjdxaPj5N0 fYV8/vZVdVMTsC8QvZEY06+HD+xOWaatprkj5WIsxxx6fh5gkoE5xoSfUTKZGNzgjWFx Bu4HDdnqNjd+puDw/kRzENupDOyNO63eEqvI5gIK0QtwhwGYThi7waAe4Dd11tCPfC5U GKoeQpG39Tb1BHeRE65yqctMSur4asnJ7PTWuS4QC6NozuXuGAzmBlbFknbtzbGyF92e jp/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si17674926edf.314.2021.03.03.21.56.07; Wed, 03 Mar 2021 21:56:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1836861AbhCBHVU (ORCPT + 99 others); Tue, 2 Mar 2021 02:21:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:45680 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1836203AbhCBGtH (ORCPT ); Tue, 2 Mar 2021 01:49:07 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 600B4AC24; Tue, 2 Mar 2021 06:48:25 +0000 (UTC) Date: Tue, 02 Mar 2021 07:48:25 +0100 Message-ID: From: Takashi Iwai To: Anton Yakovlev Cc: , , , "Michael S. Tsirkin" , Jaroslav Kysela , Takashi Iwai , Subject: Re: [PATCH v6 9/9] ALSA: virtio: introduce device suspend/resume support In-Reply-To: <7d4daea0-ed59-e84c-c28a-945c49204c83@opensynergy.com> References: <20210227085956.1700687-1-anton.yakovlev@opensynergy.com> <20210227085956.1700687-10-anton.yakovlev@opensynergy.com> <7d4daea0-ed59-e84c-c28a-945c49204c83@opensynergy.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 02 Mar 2021 07:29:20 +0100, Anton Yakovlev wrote: > > On 28.02.2021 13:05, Takashi Iwai wrote: > > On Sat, 27 Feb 2021 09:59:56 +0100, > > Anton Yakovlev wrote: > >> > > [snip] > > >> --- a/sound/virtio/virtio_pcm.c > >> +++ b/sound/virtio/virtio_pcm.c > >> @@ -109,6 +109,7 @@ static int virtsnd_pcm_build_hw(struct virtio_pcm_substream *vss, > >> SNDRV_PCM_INFO_BATCH | > >> SNDRV_PCM_INFO_BLOCK_TRANSFER | > >> SNDRV_PCM_INFO_INTERLEAVED | > >> + SNDRV_PCM_INFO_RESUME | > >> SNDRV_PCM_INFO_PAUSE; > > > > Actually you don't need to set SNDRV_PCM_INFO_RESUME. > > This flag means that the driver supports the full resume procedure, > > which isn't often the case; with this, the driver is supposed to > > resume the stream exactly from the suspended position. > > > > Most drivers don't set this but implement only the suspend-stop > > action. Then the application (or the sound backend) will re-setup the > > stream and restart accordingly. > > I tried to resume driver without SNDRV_PCM_INFO_RESUME, and alsa-lib > called only ops->prepare(). It makes sense for a typical hw, but we have > "clean" unconfigured device on resume. And we must set hw parameters as > a first step. It means, that code should be more or less the same. And > maybe it's better to set SNDRV_PCM_INFO_RESUME, since it allows us to > resume substream in any situation (regardless of application behavior). > I can refactor code to only send requests from trigger(RESUME) path and > not to call ops itself. It should make code more straitforward. What do > you say? How about calling hw_params(NULL) conditionally in the prepare? Doing the full stack work in the trigger callback is bad from the API design POV; in general the trigger callback is supposed to be as short as possible. Takashi