From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 14 16:54:24 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7289106564A; Fri, 14 Oct 2011 16:54:24 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5ECD78FC13; Fri, 14 Oct 2011 16:54:24 +0000 (UTC) Received: by vcbfo13 with SMTP id fo13so1422236vcb.13 for ; Fri, 14 Oct 2011 09:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2gN4F8qJD0pe7sZZRtfqlwwE/HQmcIbZtX3+PO5trd4=; b=aAepuPJ+v+M1u7T3ZlrmV36c2zZfOoZFp7cIfR6lYZLkCSHFkEQetoDJL8ZmTJ8edn Dvio0eVE3mbhy/qxf1NoRySLg5adcQ4bsOkNgTR7M/YcYyIjuqq9EN3obJQOgIdywB4n WkLljgAZDiFSYppe3Dm8jpD+QQ4nlEYIDxdhM= MIME-Version: 1.0 Received: by 10.182.124.9 with SMTP id me9mr5064838obb.1.1318609701834; Fri, 14 Oct 2011 09:28:21 -0700 (PDT) Received: by 10.182.220.1 with HTTP; Fri, 14 Oct 2011 09:28:21 -0700 (PDT) In-Reply-To: References: Date: Fri, 14 Oct 2011 20:28:21 +0400 Message-ID: From: Sergey Kandaurov To: Maxim Ignatenko Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-hackers@freebsd.org, freebsd-acpi@freebsd.org Subject: Re: Acquiring ACPI_LOCK(acpi) from kernel module during boot process X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2011 16:54:24 -0000 On 14 October 2011 16:11, Maxim Ignatenko wrote: > Hi, > > I have this code: > https://gitorious.org/acpi_call-freebsd/acpi_call-freebsd/blobs/5e6a79869721a2bd8de88b5cfa90c14b429cb5c7/acpi_call.c > It works just fine when loaded into kernel manually, but crashes if > loaded during boot via loader.conf: http://i.imgur.com/fLPen.png > > I've added some printf's to acpi_register_ioctl() to track down where > it hangs and crashes after about one minute: > http://pastebin.com/vvJutWLA > > What am I missing? Do I need to somehow (how?) specify module > initialization order? Or just call acpi_register_ioctl() by some other > mean when it would not cause panic? > Hi. The call of mtx_lock_spin() (as seen from your attached screenshot) on MTX_DEF acpi mutex tells me that you try to use it before it was initialized. This is usually done in acpi_attach() routine which is called with SI_SUB_DRIVERS (? - correct me if I'm wrong) order. Your module is initialized with the earlier SI_SUB_KLD order. That also might depend on whether acpi.ko is statically compiled in, even though you have MODULE_DEPEND(acpi_call, acpi, 1, 1, 1); First I would change the order in DECLARE_MODULE() to a more common SI_SUB_EXEC. -- wbr, pluknet