Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp694979pxb; Thu, 25 Feb 2021 12:38:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyP8qHGQGUy4kmcqyNTuedFt4D1/jx77QXXmw4APR0bJuSMi5g5jxHRqpNg9gWxKyYLZbTH X-Received: by 2002:a50:fe86:: with SMTP id d6mr4966134edt.80.1614285484550; Thu, 25 Feb 2021 12:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614285484; cv=none; d=google.com; s=arc-20160816; b=caSSHposHGHG4Q0ljzoFmM264FV0f5bT+KAWmLthk9d1q/LJwN5je/6jAvN365SMHy Xb0sgzIdI2v+3q7I87+StNXi4JJFczFW2VLlE2E+ID5zzVUJtTPLQcVaFpNKOw73yiBn b3wXB4lkOOzOHqo2om2Mdzbblk/cw6R9N2a8ZVxVdwbp5IhhV/Ubs1GE+kUIxY+MddlJ 7NZl9R0oEuEaWLSC3l3zpeOlx8vQ0L0yTGJ6bE75kibho64pMsKVi5y6mBAUgGtMG+m6 2C6YIk+SREZ2KRFMGXQLRToTg6pa/X8owm2PPhyA/hK2j1jzEPGMsvbBBV+LpwVh8nB9 M6SA== 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=wcruzTaGR+UQOe36EEwTdP03cVP+MjVGc42lqHVIvwI=; b=K5wPOS88iBtVv57u5HS/t0ETX2XVRisPJ04GMVzqHarNOD6MUc4KlUAq9I5C0+pgPb 6tmtrG3WYmA6ixwlb9BTFwdZtOaW/T7G0lmRmxk/n5F2iOWvHGQjLxf7WFvY9ZlUSG0a Tuo7/xYzlnGUi5LNHYkXmtV3HbG0XSO1Z424iLtI17aN9p8LfbHXkvqIda7Y1Bi/fEnm UGASATvIlku6Z09/ZDLUBfPqjQg+yVDmoFLh3gPm3QXxaqJdkhT6e0JECJ9Y9EnYQwWg rPC2EFTRmfEFTQjKdT6UNBZmyXEhEj0Yv4mWdrrG+K63OcQQXuIx0tHkvRNDfeFJTkLX dOfA== 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 dj3si4259204edb.206.2021.02.25.12.37.41; Thu, 25 Feb 2021 12:38:04 -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 S233403AbhBYUfJ (ORCPT + 99 others); Thu, 25 Feb 2021 15:35:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:52006 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234358AbhBYUbd (ORCPT ); Thu, 25 Feb 2021 15:31:33 -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 C5AFAAF72; Thu, 25 Feb 2021 20:30:51 +0000 (UTC) Date: Thu, 25 Feb 2021 21:30:51 +0100 Message-ID: From: Takashi Iwai To: "Michael S. Tsirkin" Cc: Anton Yakovlev , virtualization@lists.linux-foundation.org, alsa-devel@alsa-project.org, virtio-dev@lists.oasis-open.org, Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 6/9] ALSA: virtio: PCM substream operators In-Reply-To: <20210225135951-mutt-send-email-mst@kernel.org> References: <20210222153444.348390-1-anton.yakovlev@opensynergy.com> <20210222153444.348390-7-anton.yakovlev@opensynergy.com> <20210225135951-mutt-send-email-mst@kernel.org> 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 Thu, 25 Feb 2021 20:02:50 +0100, Michael S. Tsirkin wrote: > > On Thu, Feb 25, 2021 at 01:51:16PM +0100, Takashi Iwai wrote: > > On Thu, 25 Feb 2021 13:14:37 +0100, > > Anton Yakovlev wrote: > > > > > > On 25.02.2021 11:55, Takashi Iwai wrote: > > > > On Mon, 22 Feb 2021 16:34:41 +0100, > > > > Anton Yakovlev wrote: > > > >> +static int virtsnd_pcm_open(struct snd_pcm_substream *substream) > > > >> +{ > > > >> + struct virtio_pcm *vpcm = snd_pcm_substream_chip(substream); > > > >> + struct virtio_pcm_substream *vss = NULL; > > > >> + > > > >> + if (vpcm) { > > > >> + switch (substream->stream) { > > > >> + case SNDRV_PCM_STREAM_PLAYBACK: > > > >> + case SNDRV_PCM_STREAM_CAPTURE: { > > > > > > > > The switch() here looks superfluous. The substream->stream must be a > > > > good value in the callback. If any, you can put WARN_ON() there, but > > > > I don't think it worth. > > > > > > At least it doesn't do any harm. > > > > It does -- it makes the readability worse, and that's a very important > > point. > > > > > >> +static int virtsnd_pcm_hw_params(struct snd_pcm_substream *substream, > > > >> + struct snd_pcm_hw_params *hw_params) > > > >> +{ > > > > .... > > > >> + return virtsnd_pcm_msg_alloc(vss, periods, period_bytes); > > > > > > > > We have the allocation, but... > > > > > > > >> +static int virtsnd_pcm_hw_free(struct snd_pcm_substream *substream) > > > >> +{ > > > >> + return 0; > > > > > > > > ... no release at hw_free()? > > > > I know that the free is present in the allocator, but it's only for > > > > re-allocation case, I suppose. > > > > > > When the substream stops, sync_ptr waits until the device has completed > > > all pending messages. This wait can be interrupted either by a signal or > > > due to a timeout. In this case, the device can still access messages > > > even after calling hw_free(). It can also issue an interrupt, and the > > > interrupt handler will also try to access message structures. Therefore, > > > freeing of already allocated messages occurs either in hw_params() or in > > > dev->release(), since there it is 100% safe. > > > > OK, then it's worth to document it about this object lifecycle. > > The buffer management of this driver is fairly unique, so otherwise it > > confuses readers. > > > > > > thanks, > > > > Takashi > > Takashi given I was in my tree for a while and I planned to merge > it this merge window. Hmm, that's too quick, I'm afraid. I see still a few rough edges in the code. e.g. the reset work should be canceled at the driver removal, but it's missing right now. And that'll become tricky because the reset work itself unbinds the device, hence it'll get stuck if calling cancel_work_sync() at remove callback. > I can still drop it but there are > unrelated patches behind these in the tree so that's a rebase > which will invalidate my testing, I'm just concerned about > meeting the merge window. > > Would it be ok to merge this as is and then address > readability stuff by patches on top? > If yes please send acks! > If you want to merge it yourself instead, also please say so. I don't mind who take the patches, although it looks more fitting to merge through sound git tree if judging from the changes put in sound/* directory. thanks, Takashi