From owner-freebsd-current@FreeBSD.ORG Thu Aug 18 06:27:44 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14F9B106566B for ; Thu, 18 Aug 2011 06:27:44 +0000 (UTC) (envelope-from jason.harmening@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 CC7E38FC0A for ; Thu, 18 Aug 2011 06:27:43 +0000 (UTC) Received: by vxh11 with SMTP id 11so1923567vxh.13 for ; Wed, 17 Aug 2011 23:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=mlbpnLwnFmg8P1rmIK6OXRb097GzYjKszO+OFv1u0Dw=; b=OKKSc2OsXKc0VfFq+wFuHdHUQRk8M1ieElogUmGM3xDRrmiHM3Zmvgyqa56XEbaW95 4QHCBIJOerntH/u4mZynHEpx8PgDxqrgD49fU48Pcx3dE5nCMEsNLpczSqY8sS3EJJe1 bYeWB0JipBEpeMwSq6TFQg9zAGlEv06lvYzo0= MIME-Version: 1.0 Received: by 10.52.21.201 with SMTP id x9mr309580vde.363.1313647394579; Wed, 17 Aug 2011 23:03:14 -0700 (PDT) Received: by 10.52.111.197 with HTTP; Wed, 17 Aug 2011 23:03:14 -0700 (PDT) Date: Thu, 18 Aug 2011 01:03:14 -0500 Message-ID: From: Jason Harmening To: freebsd-current@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Mailman-Approved-At: Thu, 18 Aug 2011 11:08:49 +0000 Subject: device_probe_and_attach() fails in kernel built w/ clang X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2011 06:27:44 -0000 Hi everyone, I have a driver for PCI devices that have onboard I2C buses, so my driver needs to create an iicbus child for the PCI device. So in my driver I use DRIVER_MODULE(iicbus, , iicbus_driver, iicbus_devclass, NULL, NULL). This works because iicbus_driver and iicbus_devclass are declared extern in iicbus.h. Then during device attachment I create the iicbus child using: device_add_child(parent, "iicbus", -1); ... device_probe_and_attach(iicbus_dev); This all works fine for a kernel built w/ gcc. But if I build the same kernel w/ clang, the device_probe_and_attach() call returns ENXIO. I was able to debug this far enough to determine that device_probe_child() in subr_bus.c wasn't finding any matching drivers, so first_matching_driver() returned NULL and the matching loops fell through. Interestingly enough, I have another driver for a similar class of devices that also uses iicbus, and if I load that driver after loading the first one, the *first* driver will be re-probed, and this time it will successfully create its iicbus devices and attach to the PCI devices. The *second* driver, though, will still fail to create its iicbuses. I'm not sure if this is some weird problem w/ the iicbus driver, with the kernel's probing routines, or with the module data structures and init calls generated by DRIVER_MODULE(). Whatever it is seems to be clang-related; removing optimization and march= from CFLAGS had no effect. I'm using r224899/amd64. Any help would be really appreciated. Cheers, Jason