Date: Wed, 23 Sep 2015 08:07:55 -0700 From: John Baldwin <jhb@freebsd.org> To: "Pokala, Ravi" <rpokala@panasas.com> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: bus_.*_resource() and rid Message-ID: <1637146.Rv3dkk0gMi@ralph.baldwin.cx> In-Reply-To: <D217B20D.1455A1%rpokala@panasas.com> References: <D214E963.145154%rpokala@panasas.com> <1685918.WyYIclYTSg@ralph.baldwin.cx> <D217B20D.1455A1%rpokala@panasas.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, September 11, 2015 02:37:58 AM Pokala, Ravi wrote: > -----Original Message----- > From: John Baldwin <jhb@freebsd.org> > Date: 2015-09-10, Thursday at 17:24 > To: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> > Cc: Ravi Pokala <rpokala@panasas.com> > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1637146.Rv3dkk0gMi>