From patchwork Mon Jan 12 15:43:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5611101 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9D7D5C058D for ; Mon, 12 Jan 2015 15:44:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BF0420531 for ; Mon, 12 Jan 2015 15:44:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0ED13202FE for ; Mon, 12 Jan 2015 15:44:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 36F76260709; Mon, 12 Jan 2015 16:44:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9F42526067A; Mon, 12 Jan 2015 16:44:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A45D82606A9; Mon, 12 Jan 2015 16:43:59 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 72A3726064E for ; Mon, 12 Jan 2015 16:43:52 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 42DC7AB09; Mon, 12 Jan 2015 15:43:52 +0000 (UTC) Date: Mon, 12 Jan 2015 16:43:51 +0100 Message-ID: From: Takashi Iwai To: Pavel Hofman In-Reply-To: <54B3872C.2010501@ivitera.com> References: <54B28174.7060008@ivitera.com> <54B2B992.7000909@ivitera.com> <54B2E48B.7020000@ivitera.com> <54B3872C.2010501@ivitera.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/24.4 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: alsa-devel Subject: Re: [alsa-devel] ESI Juli@ crash with external clock switch - patch X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP At Mon, 12 Jan 2015 09:34:52 +0100, Pavel Hofman wrote: > > On 12.1.2015 09:21, Takashi Iwai wrote: > > Yeah, restart is necessary only in a certain situation, and is a bug > > that is done through work itself. This was the cause. I'll prepare > > fix patches later. > > I wish I could help but unfortunately my practical knowledge of kernel > workqueues is close to zero :-( Of course I will test the patches and > will extend them for quartet with testing too. How about the patch below? This is a quick fix for 3.19 (and stable). More better fixes will follow later once after it's confirmed to work. > > The HZ/10 isn't that bad, but the problem is that it's unconditionally > > running even if user doesn't need/want. > > It is useful only for the external clock mode. In fact the detection of > incoming SPDIF rate is not reliable for internal clock in Juli (while it > works just fine in Quartet, its FPGA pins configure the SPDIF receiver > differently). IMO the thread could be running only when clock is > switched to external. Yeah, we can do some smart task change in addition to manual on/off. Maybe it's good to have an enum control for that. Takashi diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h index 52f02a60dba7..796834b7790c 100644 --- a/include/sound/ak4114.h +++ b/include/sound/ak4114.h @@ -169,6 +169,7 @@ struct ak4114 { ak4114_read_t * read; void * private_data; unsigned int init: 1; + bool in_workq; spinlock_t lock; unsigned char regmap[6]; unsigned char txcsb[5]; diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index c7f56339415d..0f923809522c 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -152,9 +152,11 @@ static void ak4114_init_regs(struct ak4114 *chip) void snd_ak4114_reinit(struct ak4114 *chip) { + if (chip->in_workq) + return; chip->init = 1; mb(); - flush_delayed_work(&chip->work); + cancel_delayed_work_sync(&chip->work); ak4114_init_regs(chip); /* bring up statistics / event queing */ chip->init = 0; @@ -612,10 +614,12 @@ static void ak4114_stats(struct work_struct *work) { struct ak4114 *chip = container_of(work, struct ak4114, work.work); - if (!chip->init) + chip->in_workq = true; + if (!chip->init) { snd_ak4114_check_rate_and_errors(chip, chip->check_flags); - - schedule_delayed_work(&chip->work, HZ / 10); + schedule_delayed_work(&chip->work, HZ / 10); + } + chip->in_workq = false; } EXPORT_SYMBOL(snd_ak4114_create);