From owner-freebsd-hackers@freebsd.org Wed Sep 23 15:09:20 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 372A5A0771E for ; Wed, 23 Sep 2015 15:09:20 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 13F731356 for ; Wed, 23 Sep 2015 15:09:20 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id A0873B913; Wed, 23 Sep 2015 11:09:18 -0400 (EDT) From: John Baldwin To: "Pokala, Ravi" Cc: "freebsd-hackers@freebsd.org" Subject: Re: bus_.*_resource() and rid Date: Wed, 23 Sep 2015 08:07:55 -0700 Message-ID: <1637146.Rv3dkk0gMi@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-PRERELEASE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: <1685918.WyYIclYTSg@ralph.baldwin.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 23 Sep 2015 11:09:18 -0400 (EDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 15:09:20 -0000 On Friday, September 11, 2015 02:37:58 AM Pokala, Ravi wrote: > -----Original Message----- > From: John Baldwin > Date: 2015-09-10, Thursday at 17:24 > To: "freebsd-hackers@freebsd.org" > Cc: Ravi Pokala > Subject: Re: bus_.*_resource() and rid > > >Each bus decides how to manage RIDs. For PCI devices, RIDs are the > >address of the corresponding BAR for memory and I/O port resources and > >follow a different convention for interrupts (0 == INTx, 1...N == > >MSI/MSI-X). For ISA devices (and ACPI) RIDs are 0...N. If a device is > >enumerated via the firmware (e.g. ACPI DSDT entry with _CRS or PNPBIOS > >data for non-ACPI) then the firmware assigned resources are set for you > >by the parent bus and start at 0 (if you have two I/O port resources > >you'd have the second one at rid 1). > > I see the address ranges w/ `devinfo -r', but they don't list RIDs. Yes, you'd have to grumble around with kgdb to see rids. We might store rids in 'struct resouce *' now so we could possibly expose those to devinfo. > >If you are doing this on the LPC, then that it is actually a PCI device, > >and I don't know if the PCI bus is really going to let you create a rid > >at 0 via bus_set_resource(). Hmm, it should, but it's kind of a bit > >hacky. It might be somewhat cleaner if instead you treat this as an ISA > >device that is a child of isa0 below the LPC device. You can use an > >identify routine that looks at the grandparent isab0 device and then > >allocates this. > > My understanding was that the *only* way to treat devices hanging off the > LPC was as an ISA device, so that's what I've been doing. That is, the LPC > controller is a transparent bridge to allow ISA devices to connect to > modern systems. (In several cases, the LPC controller also has some BARs > which point at integrated ISA devices, like GPIO controllers, but that's > beside the point.) Some drivers take over the LPC (e.g. I think some of the smb controllers do this) and provide functionality directly in the driver attached to the LPC rather than as a child. In general I think it is cleaner to provide these extended functionalities as pseudo-ISA devices that are children of the LPC instead. The relevant SMB drivers that do the other way: viapm/viapm.c:DRIVER_MODULE(isa, viapm, isa_driver, isa_devclass, 0, 0); viapm/viapm.c:DRIVER_MODULE(isa, viapropm, isa_driver, isa_devclass, 0, 0); > >However, a rid of 0 "should" work. You can check the resource list of > >the device in kgdb to see if there's a valid resource entry for rid 0. > >You could also try calling bus_get_resource() in your attach routine to > >see if the bus_set_resource() "worked". > > I'll look into bus_get_resource(). Oh, look - there's no manpage > (share/man/man9/bus_get_resource.9 does not exist, despite being a "see > also" entry in bus_set_resource.9). :-S Time for Someone(tm) to write one. :-/ -- John Baldwin