From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 E3ED3C433DB for ; Tue, 26 Jan 2021 17:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5A8D206D4 for ; Tue, 26 Jan 2021 17:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387904AbhAZRb1 (ORCPT ); Tue, 26 Jan 2021 12:31:27 -0500 Received: from mga01.intel.com ([192.55.52.88]:64921 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732046AbhAZHgo (ORCPT ); Tue, 26 Jan 2021 02:36:44 -0500 IronPort-SDR: 8CcabyWhltogZNTQFtR2GXT3XplAHNFBryKzWYj+8BgnP9dAHs+ibWiyNBQMb/jW6bqUKtHqbP 0PIotnA14Tqg== X-IronPort-AV: E=McAfee;i="6000,8403,9875"; a="198645450" X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="198645450" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 23:26:02 -0800 IronPort-SDR: Sd5dS09jU/hBm6xU+DWJk8sUX/O9t+7dGZwRVHfAOilhhBCQCOJTOb8K/pIcZfNyzFi2khNo+8 eiASdJp37QAg== X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="387723377" Received: from kleve-mobl1.ger.corp.intel.com (HELO ubuntu) ([10.252.52.33]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 23:26:00 -0800 Date: Tue, 26 Jan 2021 08:25:58 +0100 (CET) From: Guennadi Liakhovetski To: Guennadi Liakhovetski cc: Anton Yakovlev , virtualization@lists.linux-foundation.org, alsa-devel@alsa-project.org, virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, Jaroslav Kysela , Takashi Iwai , "Michael S. Tsirkin" Subject: Re: [PATCH v2 6/9] ALSA: virtio: PCM substream operators In-Reply-To: <7b4fa4c1-4af1-47b5-d2e6-bb2f81e75488@intel.com> Message-ID: References: <20210124165408.1122868-1-anton.yakovlev@opensynergy.com> <20210124165408.1122868-7-anton.yakovlev@opensynergy.com> <7b4fa4c1-4af1-47b5-d2e6-bb2f81e75488@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org One more thing I missed yesterday: On Mon, 25 Jan 2021, Guennadi Liakhovetski wrote: > > On Sun, 24 Jan 2021, Anton Yakovlev wrote: > >> Introduce the operators required for the operation of substreams. >> >> Signed-off-by: Anton Yakovlev >> --- >> sound/virtio/Makefile | 3 +- >> sound/virtio/virtio_pcm.c | 5 +- >> sound/virtio/virtio_pcm.h | 2 + >> sound/virtio/virtio_pcm_ops.c | 513 ++++++++++++++++++++++++++++++++++ >> 4 files changed, 521 insertions(+), 2 deletions(-) >> create mode 100644 sound/virtio/virtio_pcm_ops.c > > [snip] > >> diff --git a/sound/virtio/virtio_pcm_ops.c b/sound/virtio/virtio_pcm_ops.c >> new file mode 100644 >> index 000000000000..19882777fcd6 >> --- /dev/null >> +++ b/sound/virtio/virtio_pcm_ops.c >> @@ -0,0 +1,513 @@ > > [snip] > >> +/** >> + * virtsnd_pcm_release() - Release the PCM substream on the device side. >> + * @substream: VirtIO substream. >> + * >> + * Context: Any context that permits to sleep. >> + * Return: 0 on success, -errno on failure. >> + */ >> +static inline bool virtsnd_pcm_released(struct virtio_pcm_substream >> *substream) >> +{ >> + /* >> + * The spec states that upon receipt of the RELEASE command "the >> device >> + * MUST complete all pending I/O messages for the specified stream >> ID". >> + * Thus, we consider the absence of I/O messages in the queue as an >> + * indication that the substream has been released. >> + */ >> + return atomic_read(&substream->msg_count) == 0; > > Also here having it atomic doesn't really seem to help. This just means, that > at some point of time it was == 0. > >> +} >> + >> +static int virtsnd_pcm_release(struct virtio_pcm_substream *substream) > > kernel-doc missing > >> +{ >> + struct virtio_snd *snd = substream->snd; >> + struct virtio_snd_msg *msg; >> + unsigned int js = msecs_to_jiffies(msg_timeout_ms); >> + int rc; >> + >> + msg = virtsnd_pcm_ctl_msg_alloc(substream, VIRTIO_SND_R_PCM_RELEASE, >> + GFP_KERNEL); >> + if (IS_ERR(msg)) >> + return PTR_ERR(msg); >> + >> + rc = virtsnd_ctl_msg_send_sync(snd, msg); >> + if (rc) >> + return rc; >> + >> + return wait_event_interruptible_timeout(substream->msg_empty, >> + virtsnd_pcm_released(substream), >> + js); wait_event_interruptible_timeout() will return a positive number in success cases, 0 means a timeout and condition still false. Whereas when you call this function you interpret 0 as success and you expect any != 0 to be a negative error. Wondering how this worked during your tests? Thanks Guennadi