From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932228AbWFHKf6 (ORCPT ); Thu, 8 Jun 2006 06:35:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932220AbWFHKf6 (ORCPT ); Thu, 8 Jun 2006 06:35:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:30859 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S932164AbWFHKf4 (ORCPT ); Thu, 8 Jun 2006 06:35:56 -0400 Date: Thu, 08 Jun 2006 12:35:42 +0200 Message-ID: From: Takashi Iwai To: Adrian McMenamin Cc: alsa-devel@alsa-project.org, Paul Mundt , Lee Revell , linux-kernel@vger.kernel.org, linux-sh Subject: Re: [Alsa-devel] [linuxsh-dev] [PATCH] Add support for Yamaha AICA sound on SEGA Dreamcast In-Reply-To: <1149704202.5087.6.camel@localhost.localdomain> References: <1149201071.9032.13.camel@localhost.localdomain> <1149334788.9065.5.camel@localhost.localdomain> <1149635448.5154.7.camel@localhost.localdomain> <1149704202.5087.6.camel@localhost.localdomain> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 MULE XEmacs/21.5 (beta25) (eggplant) (+CVS-20060326) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org At Wed, 07 Jun 2006 19:16:42 +0100, Adrian McMenamin wrote: > > On Wed, 2006-06-07 at 11:51 +0200, Takashi Iwai wrote: > > At Wed, 07 Jun 2006 00:10:48 +0100, > > Adrian McMenamin wrote: > > > > > > On Tue, 2006-06-06 at 12:25 +0200, Takashi Iwai wrote: > > > > > > > Another big concern is that spu_dma_work is initialized/rewritten > > > > dynamically in spu_begin_dma() and aica_period_elapsed() via > > > > INIT_WORK() and PREPARE_WOR(). This looks pretty strange and may be > > > > racy. > > > > > > Actually, the two macros INIT_WORK and PREPARE_WORK use the same work > > > queue but ask it to schedule the execution of two different (if very > > > similar) functions start_spu_dma() - which does the initial transfer and > > > more_spu_dma - which tops up the dma transfers. > > > > > > So I think I've got that right. > > > > What's wrong with using two individual work struct so that you > > initialize them only once? > > I wonder it because you already have unused fields work and work2... > > > They've gone actually. > > I need to initialise them because every call is a discrete processing > job - ie I send one thing to go, then when a period has elapsed I > schedule another transfer to run on the kernel thread. > > Isn't this the way it is meant to work? It's uncoventional that a work struct is re-initialized on the fly. IMO, it's better to introduce a flag indicating the stream is already running and use a single function/work struct. For example, static void do_first_event(struct stream *str) { ... str->running = 1; } static void do_more_event(struct stream *str) { ... } static void work_event(void *data) { struct stream *str = data; if (str->running) do_more_event(str); else do_first_event(str); } trigger_start() { queue_work(queue, &this_work); } interrupt_handler() { ... queue_work(queue, &this_work); ... } initialization() { ... queue = create_workqueue("xxx"); INIT_WORK(&this_work, work_event, str); ... }