From patchwork Sun Jun 6 12:43:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zidlicky X-Patchwork-Id: 104548 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o56CeHip013117 for ; Sun, 6 Jun 2010 12:40:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755883Ab0FFMjm (ORCPT ); Sun, 6 Jun 2010 08:39:42 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:36355 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752047Ab0FFMjl (ORCPT ); Sun, 6 Jun 2010 08:39:41 -0400 Received: by bwz11 with SMTP id 11so727979bwz.19 for ; Sun, 06 Jun 2010 05:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=jGLH/2UXMMYZil1xCVmcIQeuDUEK18dxANeA5e/75wY=; b=np9v2P1Dow27PeI7+AO/SwQmHtuGm0HMZO6sxGoesKQm4zPGyRvkEC7/RWT1IrWgBb OFERB3ufD5T6VjM2Ylbumsn2vgWSACb9YaeVdyoDpnhnureKdIP8XM1MfIcq+n6/snWu /EGsgqUXtCPqT/qaUsvqIM2TuQ3yCZZvQvN6Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=U3wOPWfmHmB7xrrMFfv3UbumggBjjRhD95O9Y3nctSWe+OTrZGiMH/rYPrV2QawaMz UIV0RmfiwwCh46C/85+yrCBNoYtjC1knyh0FSUPNXKWIrV9feY2mXr/ZourwcRZ7TguQ mTWKb1ZNecMsjsXiKZiZjnEKMUyjsygHsgDms= Received: by 10.204.81.7 with SMTP id v7mr5561770bkk.140.1275827977778; Sun, 06 Jun 2010 05:39:37 -0700 (PDT) Received: from localhost.localdomain (184.121.113.82.net.de.o2.com [82.113.121.184]) by mx.google.com with ESMTPS id z20sm14683231bkx.15.2010.06.06.05.39.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 06 Jun 2010 05:39:36 -0700 (PDT) Received: from rz by localhost.localdomain with local (Exim 4.69) (envelope-from ) id 1OLFBv-0002fT-1S; Sun, 06 Jun 2010 14:43:03 +0200 Date: Sun, 6 Jun 2010 14:43:02 +0200 From: Richard Zidlicky To: Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 2.6.34] schedule inside spin_lock_irqsave Message-ID: <20100606124302.GA10119@linux-m68k.org> References: <20100530145240.GA21559@linux-m68k.org> <4C028336.8030704@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4C028336.8030704@gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 06 Jun 2010 12:40:17 +0000 (UTC) --- linux-2.6.34/drivers/media/dvb/siano/smscoreapi.c.rz 2010-06-03 21:58:11.000000000 +0200 +++ linux-2.6.34/drivers/media/dvb/siano/smscoreapi.c 2010-06-04 23:00:35.000000000 +0200 @@ -1100,31 +1100,26 @@ * * @return pointer to descriptor on success, NULL on error. */ -struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev) + +struct smscore_buffer_t *get_entry(void) { struct smscore_buffer_t *cb = NULL; unsigned long flags; - DEFINE_WAIT(wait); - spin_lock_irqsave(&coredev->bufferslock, flags); - - /* This function must return a valid buffer, since the buffer list is - * finite, we check that there is an available buffer, if not, we wait - * until such buffer become available. - */ - - prepare_to_wait(&coredev->buffer_mng_waitq, &wait, TASK_INTERRUPTIBLE); - - if (list_empty(&coredev->buffers)) - schedule(); - - finish_wait(&coredev->buffer_mng_waitq, &wait); - + if (!list_empty(&coredev->buffers)) { cb = (struct smscore_buffer_t *) coredev->buffers.next; list_del(&cb->entry); - + } spin_unlock_irqrestore(&coredev->bufferslock, flags); + return cb; +} + +struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev) +{ + struct smscore_buffer_t *cb = NULL; + + wait_event(coredev->buffer_mng_waitq, (cb = get_entry())); return cb; }