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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 EB402C433DB for ; Wed, 3 Feb 2021 18:08:51 +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 8334164F5C for ; Wed, 3 Feb 2021 18:08:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8334164F5C 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-devel-bounces@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 0ABB81715; Wed, 3 Feb 2021 19:07:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0ABB81715 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1612375728; bh=HrMYWIJRRm9fuzgWH+Inm+5Ks8Y6YQ7y9RPNjpWTxk4=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=K46ymvO6oqL6F2dbsgAqS8cSgZaL9BUqn5nrH+T2V0rlHkft+9eHdjbSAI54b7nX4 OvW0WjRLjL8U6+8t7xFFCgIVktoxNkZPHnoOdy1vH2oPNrowhmd0jChWvKurq3vNKh 8DlS1AOOKw6ydkToz0H4Ot+mHWDq/wCAA+JWg86Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 880A3F80156; Wed, 3 Feb 2021 19:07:57 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 47862F8015A; Wed, 3 Feb 2021 19:07:56 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3C9CAF80155 for ; Wed, 3 Feb 2021 19:07:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3C9CAF80155 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 DD7C4ACB7; Wed, 3 Feb 2021 18:07:46 +0000 (UTC) Date: Wed, 03 Feb 2021 19:07:46 +0100 Message-ID: From: Takashi Iwai To: Anton Yakovlev Subject: Re: [PATCH v2 0/9] ALSA: add virtio sound driver In-Reply-To: <20210124165408.1122868-1-anton.yakovlev@opensynergy.com> References: <20210124165408.1122868-1-anton.yakovlev@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 Cc: virtio-dev@lists.oasis-open.org, alsa-devel@alsa-project.org, "Michael S. Tsirkin" , Takashi Iwai , virtualization@lists.linux-foundation.org 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 Sun, 24 Jan 2021 17:53:59 +0100, Anton Yakovlev wrote: > > This series implements a driver part of the virtio sound device > specification v8 [1]. > > The driver supports PCM playback and capture substreams, jack and > channel map controls. A message-based transport is used to write/read > PCM frames to/from a device. > > The series is based (and was actually tested) on Linus's master > branch [2], on top of > > commit 1e2a199f6ccd ("Merge tag 'spi-fix-v5.11-rc4' of ...") > > As a device part was used OpenSynergy proprietary implementation. > > Any comments are very welcome. > > v1->v2 changes: > > 1. For some reason, in the previous patch series, several patches were > squashed. Fixed this issue to make the review easier. > 2. Added mst@redhat.com to the MAINTAINERS. > 3. When creating virtqueues, now only the event virtqueue is disabled. > It's enabled only after successful initialization of the device. > 4. Added additional comments to the reset worker function: > [2/9] virtio_card.c:virtsnd_reset_fn() > 5. Added check that VIRTIO_F_VERSION_1 feature bit is set. > 6. Added additional comments to the device removing function: > [2/9] virtio_card.c:virtsnd_remove() > 7. Added additional comments to the tx/rx interrupt handler: > [5/9] virtio_pcm_msg.c:virtsnd_pcm_msg_complete() > 8. Added additional comments to substream release wait function. > [6/9] virtio_pcm_ops.c:virtsnd_pcm_released() > > [1] https://lists.oasis-open.org/archives/virtio-dev/202003/msg00185.html > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > Anton Yakovlev (9): > uapi: virtio_ids: add a sound device type ID from OASIS spec > ALSA: virtio: add virtio sound driver > ALSA: virtio: handling control messages > ALSA: virtio: build PCM devices and substream hardware descriptors > ALSA: virtio: handling control and I/O messages for the PCM device > ALSA: virtio: PCM substream operators > ALSA: virtio: introduce jack support > ALSA: virtio: introduce PCM channel map support > ALSA: virtio: introduce device suspend/resume support Through a quick glance over the new series, below are some comments (sorry not putting in each patch): - The PCM buffer management can be simplified with the recently introduced API, snd_pcm_set_managed_buffer() and *_all(). BTW, I wondered why you need to iterate do preallocation for each; can't the *_all() function work in a shot? - The PCM ops has sync_stop that is performed before prepare, hw_parms and else after a stream is stopped via trigger(STOP). This can be used for synchronizing things as found in your driver code. - I'm wondering whether you can use the non-atomic PCM ops. Is any interrupt handling (or spinlocked context) involved in the interface? If not, you can set nonatomic flag, and this would simply things. - Does the buffer type have to be CONTINUOUS? Can't the vmalloc buffer work? - Is the buffer supposed to be aligned with the period size? i.e. is the configuration like period=200 buffer=500 supposed to work? If the period-size alignment is needed, the driver requires an additional hw_constraint setup to make PERIODS integer. - In general, "stream", and "subtream" variables are used in mixed ways for both ALSA and virtio objects, and it's hard to follow. Maybe some prefix would help. - Don't PCM stream names need to be unique? They are all the same string. - Leave the card->id without changing unless you need to set it up explicitly by some extra reason. Also, card->shortname should be a bit more verbose and descriptive. It's a free-string while card->drier is an ID string that is used as a lookup key in alsa-lib. thanks, Takashi