From patchwork Fri Jul 9 18:01:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marko Ristola X-Patchwork-Id: 111090 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o69I1uqV002641 for ; Fri, 9 Jul 2010 18:01:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754315Ab0GISBz (ORCPT ); Fri, 9 Jul 2010 14:01:55 -0400 Received: from emh02.mail.saunalahti.fi ([62.142.5.108]:60234 "EHLO emh02.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754251Ab0GISBy convert rfc822-to-8bit (ORCPT ); Fri, 9 Jul 2010 14:01:54 -0400 Received: from saunalahti-vams (vs3-10.mail.saunalahti.fi [62.142.5.94]) by emh02-2.mail.saunalahti.fi (Postfix) with SMTP id 092D573A46; Fri, 9 Jul 2010 21:01:53 +0300 (EEST) Received: from emh07.mail.saunalahti.fi ([62.142.5.117]) by vs3-10.mail.saunalahti.fi ([62.142.5.94]) with SMTP (gateway) id A072F102498; Fri, 09 Jul 2010 21:01:53 +0300 Received: from tammi.koti (a88-114-153-83.elisa-laajakaista.fi [88.114.153.83]) by emh07.mail.saunalahti.fi (Postfix) with ESMTP id A41C41C6382; Fri, 9 Jul 2010 21:01:50 +0300 (EEST) Message-ID: <4C37640E.8090909@kolumbus.fi> Date: Fri, 09 Jul 2010 21:01:50 +0300 From: Marko Ristola User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Thunderbird/3.0.5 MIME-Version: 1.0 To: =?UTF-8?B?QmrDuHJuIE1vcms=?= , Linux Media Mailing List Subject: Re: [PATCH] Mantis: append tasklet maintenance for DVB stream delivery References: <4C1DFD75.3080606@kolumbus.fi> <87vd9dbyng.fsf@nemi.mork.no> In-Reply-To: <87vd9dbyng.fsf@nemi.mork.no> X-Antivirus: VAMS 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]); Fri, 09 Jul 2010 18:01:57 +0000 (UTC) Resending into linux-media, for confirming authorship: I have personally done this patch. Acked-by: Marko M Ristola Regards, Marko 20.06.2010 16:51, Bjørn Mork kirjoitti: > Note that mantis_core_exit() is never called. Unless I've missed > something, the drivers/media/dvb/mantis/mantis_core.{h,c} files can > just be deleted. They look like some development leftovers? > > I see. mantis_core.ko kernel module exists though. Maybe the mantis/Makefile references for mantis_core.c, mantis.c and hopper.c are just some leftovers too. I moved tasklet_enable/disable calls into mantis_dvb.c where almost all other tasklet code is located. So the following reasoning still holds: 1. dvb_dmxdev_filter_stop() calls mantis_dvb_stop_feed: mantis_dma_stop() 2. dvb_dmxdev_filter_stop() calls release_ts_feed() or some other filter freeing function. 3. tasklet: mantis_dma_xfer calls dvb_dmx_swfilter to copy DMA buffer's content into freed memory, accessing freed spinlocks. This case might occur while tuning into another frequency. Perhaps cdurrhau has found some version from this bug at http://www.linuxtv.org/pipermail/linux-dvb/2010-June/032688.html: > This is what I get on the remote console via IPMI: > 40849.442492] BUG: soft lockup - CPU#2 stuck for 61s! [section > handler:4617] New reasoning for the patch (same as the one above, but from higher level): After dvb-core has called mantis-fe->stop_feed(dvbdmxfeed) the last time (count to zero), no data should ever be copied with dvb_dmx_swfilter() by a tasklet: the target structure might be in an unusable state. Caller of mantis_fe->stop_feed() assumes that feeding is stopped after stop_feed() has been called, ie. dvb_dmx_swfilter() isn't running, and won't be called. There is a risk that dvb_dmx_swfilter() references freed resources (memory or spinlocks or ???) causing instabilities. Thus tasklet_disable(&mantis->tasklet) must be called inside of mantis-fe->stop_feed(dvbdmxfeed) when necessary. Signed-off-by: Marko Ristola Marko --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/dvb/mantis/mantis_dvb.c b/drivers/media/dvb/mantis/mantis_dvb.c index 99d82ee..a9864f7 100644 --- a/drivers/media/dvb/mantis/mantis_dvb.c +++ b/drivers/media/dvb/mantis/mantis_dvb.c @@ -117,6 +117,7 @@ static int mantis_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) if (mantis->feeds == 1) { dprintk(MANTIS_DEBUG, 1, "mantis start feed & dma"); mantis_dma_start(mantis); + tasklet_enable(&mantis->tasklet); } return mantis->feeds; @@ -136,6 +137,7 @@ static int mantis_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) mantis->feeds--; if (mantis->feeds == 0) { dprintk(MANTIS_DEBUG, 1, "mantis stop feed and dma"); + tasklet_disable(&mantis->tasklet); mantis_dma_stop(mantis); } @@ -216,6 +218,7 @@ int __devinit mantis_dvb_init(struct mantis_pci *mantis) dvb_net_init(&mantis->dvb_adapter, &mantis->dvbnet, &mantis->demux.dmx); tasklet_init(&mantis->tasklet, mantis_dma_xfer, (unsigned long) mantis); + tasklet_disable(&mantis->tasklet); if (mantis->hwconfig) { result = config->frontend_init(mantis, mantis->fe); if (result < 0) {