Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp474916pxb; Wed, 3 Feb 2021 09:42:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYye/4phNPSGYtR6npCW2QUz80KALJwStpe2Wy/Bo++NbUcuFAf/tzVBVIYA2u+d9fJ4gC X-Received: by 2002:a17:906:80b:: with SMTP id e11mr4270520ejd.269.1612374132444; Wed, 03 Feb 2021 09:42:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612374132; cv=none; d=google.com; s=arc-20160816; b=y++CJT+wjep059VGxb6cLhMXBD4NOfcMfjE/LkFvStQWe0/IZ79EmALVNx14Ey+YvX jVOo3SgUBjEjjs82e8iFhEzbK8kKTyWa2ywcJa0iqF198f826uYQgT/fS2e7ue/Cp5uO dvkOulPZ+EXHME4hqGdY+VWa09Z4LbvwNjqioPsXkqN4jOOPsL8b77IDp2Q9AmmnF2zL rR1dFxbjJiDRvRGl7deY9W2Jvl2VaKOiGylgRDnP89wtg3hpnoIjepMw/8ZvaX4Tufcz +dLIYDUeI4J+B6Y+b7NU+urJPAU2U5ShldY9eEdMLcCcZLbRIaZSKkfi2R9d6PbSkQGM Pw1g== 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=chJHd/frMF+omYycZZ19G+oSuqEXcj791KYUS0WyXrg=; b=ow/2oyqdahMUX6CEfVS6x6M3+NQ6FYLq/JB55GziEdL5ZFvjVkn8TBCEk6x1vuGHrC +Hf3ITn4C0K0Mj2WHdKQWUt+2PwdarfaGp8/voYxzEtzQ6eAOWIXnQWmsD0hRlI6wPk9 JZooG1soZ2PQ9pTlo1MC45qEu4Bj3fiQfs3SIxI8gYEChxDhPdYGEUBOqRqbgLX9yRgq vRk5RYHD+rfdJZdYweN+JYoGT6LkhIRqsxVpw1YAn4c44HIImJHVU4jWVmxklomaDxXA wJkIubHxthm3+062w2uECwE1I1DRMT7H/IaIP4XqNF1wY68T86921jilIsJgH26W1Gm2 +Ocw== 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 dn22si1936880edb.268.2021.02.03.09.41.44; Wed, 03 Feb 2021 09:42:12 -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 S231626AbhBCRkn (ORCPT + 99 others); Wed, 3 Feb 2021 12:40:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:50088 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbhBCRkl (ORCPT ); Wed, 3 Feb 2021 12:40:41 -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 A736EACB7; Wed, 3 Feb 2021 17:39:59 +0000 (UTC) Date: Wed, 03 Feb 2021 18:39:59 +0100 Message-ID: From: Takashi Iwai To: Anton Yakovlev Cc: Guennadi Liakhovetski , , , , , Jaroslav Kysela , Takashi Iwai , "Michael S. Tsirkin" Subject: Re: [virtio-dev] Re: [PATCH v2 2/9] ALSA: virtio: add virtio sound driver In-Reply-To: References: <20210124165408.1122868-1-anton.yakovlev@opensynergy.com> <20210124165408.1122868-3-anton.yakovlev@opensynergy.com> <8754dae8-114-6383-510-de2ba9dc4fa@intel.com> <52f71ac6-3ec7-2884-7a64-1995f416d20a@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 Wed, 03 Feb 2021 18:34:12 +0100, Anton Yakovlev wrote: > > Hi Takashi, > > > On 03.02.2021 17:59, Takashi Iwai wrote: > > On Tue, 02 Feb 2021 00:18:09 +0100, > > Anton Yakovlev wrote: > >>>> +/** > >>>> + * virtsnd_reset_fn() - Kernel worker's function to reset the device. > >>>> + * @work: Reset device work. > >>>> + * > >>>> + * Context: Process context. > >>>> + */ > >>>> +static void virtsnd_reset_fn(struct work_struct *work) > >>>> +{ > >>>> + struct virtio_snd *snd = > >>>> + container_of(work, struct virtio_snd, reset_work); > >>>> + struct virtio_device *vdev = snd->vdev; > >>>> + struct device *dev = &vdev->dev; > >>>> + int rc; > >>>> + > >>>> + dev_info(dev, "sound device needs reset\n"); > >>>> + > >>>> + /* > >>>> + * It seems that the only way to properly reset the device is to > >>>> remove > >>>> + * and re-create the ALSA sound card device. > >>>> + * > >>>> + * Also resetting the device involves a number of steps with > >>>> setting the > >>>> + * status bits described in the virtio specification. And the > >>>> easiest > >>>> + * way to get everything right is to use the virtio bus interface. > >>>> + */ > >>>> + rc = dev->bus->remove(dev); > >>>> + if (rc) > >>>> + dev_warn(dev, "bus->remove() failed: %d", rc); > >>>> + > >>>> + rc = dev->bus->probe(dev); > >>>> + if (rc) > >>>> + dev_err(dev, "bus->probe() failed: %d", rc); > >>> > >>> This looks very suspicious to me. Wondering what ALSA maintainers > >> will say > >>> to this. > >> > >> I'm also wondering what the virtio people have to say. This part is a > >> purely virtio specific thing. And since none of the existing virtio > >> drivers processes the request to reset the device, it is not clear what > >> is the best way to proceed here. For this reason, the most > >> straightforward and simple solution was chosen. > > > > What is this "reset" actually supposed to do? Reconfguring > > everything, or changing only certain parameters, devices, whatever? > > It means bringing this particular device to its initial state. > > After that, the driver can re-read the configurations from the device > and reconfigure everything. So all running processes have to be finished before starting resetting? It sounds indeed like a complete device re-binding, and if so, doing with the proper dev_*() API might be saner than the brute force bus->remove() and bus->probe() calls... thanks, Takashi