From owner-freebsd-drivers@FreeBSD.ORG Wed Jan 18 18:21:31 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 42BE216A422 for ; Wed, 18 Jan 2006 18:21:31 +0000 (GMT) (envelope-from kimblydavis@yahoo.com) Received: from web30005.mail.mud.yahoo.com (web30005.mail.mud.yahoo.com [68.142.200.68]) by mx1.FreeBSD.org (Postfix) with SMTP id C858143D46 for ; Wed, 18 Jan 2006 18:21:30 +0000 (GMT) (envelope-from kimblydavis@yahoo.com) Received: (qmail 20357 invoked by uid 60001); 18 Jan 2006 18:21:30 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=N+IbVYDh02RN/k4ERs/pbzaRzdAKShbUWTc1TLsOD1Redo36TzoXpGKTHnFqGN4akjU1FCKNUBtblv8z4YYlJBETd2OoWlHmKPY2PhyL0xZajqyemT/w+sLIjopsnNHVoCRiinPxNIj97HIt7pEvML1t9F3wyPxgv6pP58NJAY0= ; Message-ID: <20060118182130.20355.qmail@web30005.mail.mud.yahoo.com> Date: Wed, 18 Jan 2006 10:21:30 -0800 (PST) From: Kimberly Davis To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Interrupt Handlers and Driver to Driver Communication X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Kimberly Davis List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jan 2006 18:21:31 -0000 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