Re: How to "detach" a foreign driver from a device so my driver can attach?
On Thursday 22 January 2009 2:15:15 am Andre Albsmeier wrote: > On Wed, 21-Jan-2009 at 14:08:37 -0500, John Baldwin wrote: > > hostb as other devices (e.g. agp(4)) need to attach to host-pci bridges as > > well. > > Would this work in 6.x as well? You wrote in another mail that > in 7.0 agp attaches to hostb. This makes me think that in 6.x > things are handled differently. Yes, 6.x does not work this way. -- John Baldwin ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: How to "detach" a foreign driver from a device so my driver can attach?
On Wed, 21-Jan-2009 at 14:08:37 -0500, John Baldwin wrote: > On Tuesday 23 December 2008 12:33:22 pm Andre Albsmeier wrote: > > On Wed, 17-Dec-2008 at 00:04:30 +0100, Andre Albsmeier wrote: > > > Hello all, > > > > > > I am writing a driver which attaches to the Host-PCI bridge. When > > > compiled into the kernel or loaded by the loader everything works > > > and the driver gets attached. This is due to the fact that I return > > > BUS_PROBE_SPECIFIC in my probe routine which gains over the -1 > > > returned by pci_hostb_probe() in i386/pci/pci_bus.c. > > > > > > However, when I want to load my driver via kldload this fails since > > > the hostb device has already been attached during kernel load (when > > > my driver was not present): > > > > > > hos...@pci0:0:0:class=0x06 card=0x11d510cf chip=0x35808086 > rev=0x02 hdr=0x00 > > > > > > What can I do to make my driver load via kldload? > > > Is there a way to detach the hostb0 from the Host-PCI bridge? > > > > Found the answer myself but will post it here in case anyone > > got a similar problem one day: I added the device detach method > > for the hostb driver to sys/i386/pci/pci_bus.c: > > > > --- sys/i386/pci/pci_bus.c.ORI 2007-08-17 08:12:33.0 +0200 > > +++ sys/i386/pci/pci_bus.c 2008-12-23 13:34:35.0 +0100 > > @@ -619,10 +619,13 @@ > > return 0; > > } > > > > +static int pci_hostb_detach(device_t dev) { return 0; } > > + > > static device_method_t pci_hostb_methods[] = { > > /* Device interface */ > > DEVMETHOD(device_probe, pci_hostb_probe), > > DEVMETHOD(device_attach,pci_hostb_attach), > > + DEVMETHOD(device_detach,pci_hostb_detach), > > DEVMETHOD(device_shutdown, bus_generic_shutdown), > > DEVMETHOD(device_suspend, bus_generic_suspend), > > DEVMETHOD(device_resume,bus_generic_resume), > > > > Now, when kldload'ing my driver, it can walk through all devices > > and detach hostb using device_detach(). > > In the case of hostb, this is wrong however. You want to attach as a child > of As I learned in the meanwhile, yes. But it was quite interesting to learn how things work when you have never been into FreeBSD driver hacking before ;-). > hostb as other devices (e.g. agp(4)) need to attach to host-pci bridges as > well. Would this work in 6.x as well? You wrote in another mail that in 7.0 agp attaches to hostb. This makes me think that in 6.x things are handled differently. If not, I will stick to my detaching while I am on 6.x (don't need agp on my 440BXs) and do it right when I have migrated to 7.x... Thanks, -Andre ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: How to "detach" a foreign driver from a device so my driver can attach?
On Tuesday 23 December 2008 12:33:22 pm Andre Albsmeier wrote: > On Wed, 17-Dec-2008 at 00:04:30 +0100, Andre Albsmeier wrote: > > Hello all, > > > > I am writing a driver which attaches to the Host-PCI bridge. When > > compiled into the kernel or loaded by the loader everything works > > and the driver gets attached. This is due to the fact that I return > > BUS_PROBE_SPECIFIC in my probe routine which gains over the -1 > > returned by pci_hostb_probe() in i386/pci/pci_bus.c. > > > > However, when I want to load my driver via kldload this fails since > > the hostb device has already been attached during kernel load (when > > my driver was not present): > > > > hos...@pci0:0:0:class=0x06 card=0x11d510cf chip=0x35808086 rev=0x02 hdr=0x00 > > > > What can I do to make my driver load via kldload? > > Is there a way to detach the hostb0 from the Host-PCI bridge? > > Found the answer myself but will post it here in case anyone > got a similar problem one day: I added the device detach method > for the hostb driver to sys/i386/pci/pci_bus.c: > > --- sys/i386/pci/pci_bus.c.ORI2007-08-17 08:12:33.0 +0200 > +++ sys/i386/pci/pci_bus.c2008-12-23 13:34:35.0 +0100 > @@ -619,10 +619,13 @@ > return 0; > } > > +static int pci_hostb_detach(device_t dev) { return 0; } > + > static device_method_t pci_hostb_methods[] = { > /* Device interface */ > DEVMETHOD(device_probe, pci_hostb_probe), > DEVMETHOD(device_attach,pci_hostb_attach), > + DEVMETHOD(device_detach,pci_hostb_detach), > DEVMETHOD(device_shutdown, bus_generic_shutdown), > DEVMETHOD(device_suspend, bus_generic_suspend), > DEVMETHOD(device_resume,bus_generic_resume), > > Now, when kldload'ing my driver, it can walk through all devices > and detach hostb using device_detach(). In the case of hostb, this is wrong however. You want to attach as a child of hostb as other devices (e.g. agp(4)) need to attach to host-pci bridges as well. -- John Baldwin ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: How to "detach" a foreign driver from a device so my driver can attach?
On Wed, 17-Dec-2008 at 00:04:30 +0100, Andre Albsmeier wrote: > Hello all, > > I am writing a driver which attaches to the Host-PCI bridge. When > compiled into the kernel or loaded by the loader everything works > and the driver gets attached. This is due to the fact that I return > BUS_PROBE_SPECIFIC in my probe routine which gains over the -1 > returned by pci_hostb_probe() in i386/pci/pci_bus.c. > > However, when I want to load my driver via kldload this fails since > the hostb device has already been attached during kernel load (when > my driver was not present): > > hos...@pci0:0:0:class=0x06 card=0x11d510cf chip=0x35808086 rev=0x02 > hdr=0x00 > > What can I do to make my driver load via kldload? > Is there a way to detach the hostb0 from the Host-PCI bridge? Found the answer myself but will post it here in case anyone got a similar problem one day: I added the device detach method for the hostb driver to sys/i386/pci/pci_bus.c: --- sys/i386/pci/pci_bus.c.ORI 2007-08-17 08:12:33.0 +0200 +++ sys/i386/pci/pci_bus.c 2008-12-23 13:34:35.0 +0100 @@ -619,10 +619,13 @@ return 0; } +static int pci_hostb_detach(device_t dev) { return 0; } + static device_method_t pci_hostb_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pci_hostb_probe), DEVMETHOD(device_attach,pci_hostb_attach), + DEVMETHOD(device_detach,pci_hostb_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), DEVMETHOD(device_resume,bus_generic_resume), Now, when kldload'ing my driver, it can walk through all devices and detach hostb using device_detach(). -Andre ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
How to "detach" a foreign driver from a device so my driver can attach?
Hello all, I am writing a driver which attaches to the Host-PCI bridge. When compiled into the kernel or loaded by the loader everything works and the driver gets attached. This is due to the fact that I return BUS_PROBE_SPECIFIC in my probe routine which gains over the -1 returned by pci_hostb_probe() in i386/pci/pci_bus.c. However, when I want to load my driver via kldload this fails since the hostb device has already been attached during kernel load (when my driver was not present): hos...@pci0:0:0:class=0x06 card=0x11d510cf chip=0x35808086 rev=0x02 hdr=0x00 What can I do to make my driver load via kldload? Is there a way to detach the hostb0 from the Host-PCI bridge? I have been digging around in the sources but didn't find something similar. In case of any hints, please CC me since I am currently travelling and can't easily read the lists at home... Thanks, -Andre ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"