From owner-freebsd-drivers@FreeBSD.ORG Thu Jan 19 12:48:03 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1D5D816A41F for ; Thu, 19 Jan 2006 12:48:03 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 922B043D53 for ; Thu, 19 Jan 2006 12:48:01 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id 14F53BD073; Thu, 19 Jan 2006 13:47:56 +0100 (CET) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13002-07; Thu, 19 Jan 2006 13:47:52 +0100 (CET) Received: from firewall.demig (p508391F0.dip0.t-ipconnect.de [80.131.145.240]) by server.absolute-media.de (Postfix) with ESMTP id F08F4BD041; Thu, 19 Jan 2006 13:47:51 +0100 (CET) Received: from ws-ew-3 (ws-ew-3.demig.intra [192.168.1.72]) by firewall.demig (8.13.5/8.13.4) with SMTP id k0JCjoeq001991; Thu, 19 Jan 2006 13:45:50 +0100 (CET) (envelope-from NKoch@demig.de) From: "Norbert Koch" To: "Kimberly Davis" , Date: Thu, 19 Jan 2006 13:45:51 +0100 Message-ID: <000001c61cf6$478ea0e0$4801a8c0@ws-ew-3.demig.intra> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal In-Reply-To: <20060118182130.20355.qmail@web30005.mail.mud.yahoo.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0 X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Cc: Subject: RE: Interrupt Handlers and Driver to Driver Communication X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jan 2006 12:48:03 -0000 >From which context/function in your driver 2 do you check g_status? Does your debug output show, that this context really becomes active? Are your drivers in the same or different source files? Or are they being loaded as different klds? Have you tried if it makes any difference to declare g_status as volatile? Any interesting compiler warnings? (Just for not forgetting to ask: You didn't by accident declare g_status twice, once at global and once static at function scope?) > -----Original Message----- > From: owner-freebsd-drivers@freebsd.org > [mailto:owner-freebsd-drivers@freebsd.org]On Behalf Of Kimberly Davis > Sent: Wednesday, January 18, 2006 7:22 PM > To: freebsd-drivers@freebsd.org > Subject: Interrupt Handlers and Driver to Driver Communication > > > I am having a very serious problem with a driver that I am > writing. Specifically, my problem is related to driver to driver > communication. I've tried to abstract the problem in my description below. > > I have a driver (let's call it Driver 1) in which I register the > interrupt handler in this way: > > tsc->irqid = 0x0; > tsc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ,&(tsc->irqid), 0, ~0, > 1, RF_SHAREABLE | RF_ACTIVE); > if(tsc->irq_res == NULL) > print_osal("Failed to allocate irq resource\n"); > else > { > error = bus_setup_intr(dev, tsc->irq_res, INTR_TYPE_MISC , > driver_one_interrupt_handler, tsc, &(tsc->handler)); > } > > My interrupt handler function is actually quite long, but there > is nothing to be done about it. There is no really good way to > make it shorter. Anyway, in Driver 2, I call a function (part of > an API that I provide in driver 1) and it returns a value: > > status = driver_one_is_operation_complete(param, param); > > The driver_one_is_operation_complete function actually returns to > Driver 2 a status variable that is set in the interrupt handler > of driver 1. > > //global for status of an event. > int g_status; > void driver_one_interrupt_handler(void * arg) > { > g_status = 0; > > if(CERTAIN_CONDITION_OCCURRED) > g_status = 1; > } > > The problem is that I never, ever get the value from the > function driver_one_is_operation_complete that I would expect. > The value returned is always 0 and never 1. However, when I check > this value in driver one's detach function, right before the end > of execution, the value is 1. > > driver_one_detach() > { > > print("g_status %x\n",g_status) > blah, blah, blah > } > > Clearly, the interrupt handler has executed and the value has > been set to one. > > In driver two, I've tried waiting 2 or 3 seconds (with the > system's delay function) before calling > driver_one_is_operation_complete, but this doesn't help either. > Is there something weird going on in the Driver to Driver communication? > > Thanks in advance for any help or clues you may be able to provide, > KD > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" >