From guido at gvr.org Thu Mar 18 00:02:29 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 00:02:41 2004 Subject: ppbus probe problem Message-ID: <20040318080230.GA87270@gvr.gvr.org> An embedded message was scrubbed... From: unknown sender Subject: no subject Date: no date Size: 1046 Url: http://lists.freebsd.org/pipermail/freebsd-new-bus/attachments/20040318/e10dd438/attachment.mht From imp at bsdimp.com Thu Mar 18 00:09:51 2004 From: imp at bsdimp.com (M. Warner Losh) Date: Thu Mar 18 00:10:01 2004 Subject: ppbus probe problem Message-ID: <20040318.161006.25162359.imp@bsdimp.com> : What is the correct way to fix the probe call incrementing problem? Typically this is done by checking to see if there's a child already. However, all the ISA drivers don't do this... At work we've worked around this problem like so: static void sub00798identify(driver_t * driver, device_t parent) { devclass_t dc; dc = devclass_find(DRIVERNAME); if (devclass_get_device(dc, 0) == NULL) { if (BUS_ADD_CHILD(parent, 0, DRIVERNAME, 0) == 0) panic("failed to add " DRIVERNAME); } } Warner From dfr at nlsystems.com Thu Mar 18 01:13:47 2004 From: dfr at nlsystems.com (Doug Rabson) Date: Thu Mar 18 01:18:42 2004 Subject: ppbus probe problem In-Reply-To: <20040318080230.GA87270@gvr.gvr.org> References: <20040318080230.GA87270@gvr.gvr.org> Message-ID: <200403180913.33873.dfr@nlsystems.com> On Thursday 18 March 2004 08:02, Guido van Rooij wrote: > As the newbus gurus, I hope you can shed a light on the following: > I am trying to resurrect tw.c into current. While modifying it, > I came across a weird problem. If you load/unload a ppbus > driver (if at all possible), each additional load/unload > leads to an additional probe the next time you load that driver. > E.g, if you add a printf to the probe function in vpo.c, you see: > > command: dmesg > beck# kldload ./vpo.ko vpo probe called > beck# kldunload ./vpo.ko > beck# kldload ./vpo.ko vpo probe called > vpo probe called > beck# kldunload ./vpo.ko > beck# kldload ./vpo.ko vpo probe called > vpo probe called > vpo probe called > > etc. > > Someone suggested that the identify function was responsible for > this: > static void > vpo_identify(driver_t *driver, device_t parent) > { > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > } > > Nowhere is the child removed from the parent at detach (also there is > no BUS_REMOVE_CHILD method). You can use device_delete_child(). The reason BUS_ADD_CHILD exists is to give the parent a chance to initialise child instance variables. > > What is the correct way to fix the probe call incrementing problem? I would use something like: static void vpo_identify(driver_t *driver, device_t parent) { device_t dev; dev = device_find_child(parent, "vpo", 0); if (!dev) BUS_ADD_CHILD(parent, 0, "vpo", -1); } From dfr at nlsystems.com Thu Mar 18 01:13:47 2004 From: dfr at nlsystems.com (Doug Rabson) Date: Thu Mar 18 01:18:43 2004 Subject: ppbus probe problem In-Reply-To: <20040318080230.GA87270@gvr.gvr.org> References: <20040318080230.GA87270@gvr.gvr.org> Message-ID: <200403180913.33873.dfr@nlsystems.com> On Thursday 18 March 2004 08:02, Guido van Rooij wrote: > As the newbus gurus, I hope you can shed a light on the following: > I am trying to resurrect tw.c into current. While modifying it, > I came across a weird problem. If you load/unload a ppbus > driver (if at all possible), each additional load/unload > leads to an additional probe the next time you load that driver. > E.g, if you add a printf to the probe function in vpo.c, you see: > > command: dmesg > beck# kldload ./vpo.ko vpo probe called > beck# kldunload ./vpo.ko > beck# kldload ./vpo.ko vpo probe called > vpo probe called > beck# kldunload ./vpo.ko > beck# kldload ./vpo.ko vpo probe called > vpo probe called > vpo probe called > > etc. > > Someone suggested that the identify function was responsible for > this: > static void > vpo_identify(driver_t *driver, device_t parent) > { > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > } > > Nowhere is the child removed from the parent at detach (also there is > no BUS_REMOVE_CHILD method). You can use device_delete_child(). The reason BUS_ADD_CHILD exists is to give the parent a chance to initialise child instance variables. > > What is the correct way to fix the probe call incrementing problem? I would use something like: static void vpo_identify(driver_t *driver, device_t parent) { device_t dev; dev = device_find_child(parent, "vpo", 0); if (!dev) BUS_ADD_CHILD(parent, 0, "vpo", -1); } From guido at gvr.org Thu Mar 18 02:05:52 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 02:06:15 2004 Subject: ppbus probe problem In-Reply-To: <200403180913.33873.dfr@nlsystems.com> References: <20040318080230.GA87270@gvr.gvr.org> <200403180913.33873.dfr@nlsystems.com> Message-ID: <20040318100553.GA88901@gvr.gvr.org> On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > I would use something like: > > static void > vpo_identify(driver_t *driver, device_t parent) > { > device_t dev; > > dev = device_find_child(parent, "vpo", 0); > if (!dev) > BUS_ADD_CHILD(parent, 0, "vpo", -1); > } So I'll update all of the ppbus drivers that way. Okay? -Guido From guido at gvr.org Thu Mar 18 02:05:52 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 02:06:15 2004 Subject: ppbus probe problem In-Reply-To: <200403180913.33873.dfr@nlsystems.com> References: <20040318080230.GA87270@gvr.gvr.org> <200403180913.33873.dfr@nlsystems.com> Message-ID: <20040318100553.GA88901@gvr.gvr.org> On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > I would use something like: > > static void > vpo_identify(driver_t *driver, device_t parent) > { > device_t dev; > > dev = device_find_child(parent, "vpo", 0); > if (!dev) > BUS_ADD_CHILD(parent, 0, "vpo", -1); > } So I'll update all of the ppbus drivers that way. Okay? -Guido From dfr at nlsystems.com Thu Mar 18 02:12:56 2004 From: dfr at nlsystems.com (Doug Rabson) Date: Thu Mar 18 02:12:57 2004 Subject: ppbus probe problem In-Reply-To: <20040318100553.GA88901@gvr.gvr.org> References: <20040318080230.GA87270@gvr.gvr.org> <20040318100553.GA88901@gvr.gvr.org> Message-ID: <200403181012.43455.dfr@nlsystems.com> On Thursday 18 March 2004 10:05, Guido van Rooij wrote: > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > > I would use something like: > > > > static void > > vpo_identify(driver_t *driver, device_t parent) > > { > > device_t dev; > > > > dev = device_find_child(parent, "vpo", 0); > > if (!dev) > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > > } > > So I'll update all of the ppbus drivers that way. Okay? I think so. Warner, do you have any objections? In an ideal world, there should be some kind of BUS_UNIDENTIFY method which a driver could use to delete the devices it created in BUS_IDENTIFY. From dfr at nlsystems.com Thu Mar 18 02:12:56 2004 From: dfr at nlsystems.com (Doug Rabson) Date: Thu Mar 18 02:12:58 2004 Subject: ppbus probe problem In-Reply-To: <20040318100553.GA88901@gvr.gvr.org> References: <20040318080230.GA87270@gvr.gvr.org> <20040318100553.GA88901@gvr.gvr.org> Message-ID: <200403181012.43455.dfr@nlsystems.com> On Thursday 18 March 2004 10:05, Guido van Rooij wrote: > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > > I would use something like: > > > > static void > > vpo_identify(driver_t *driver, device_t parent) > > { > > device_t dev; > > > > dev = device_find_child(parent, "vpo", 0); > > if (!dev) > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > > } > > So I'll update all of the ppbus drivers that way. Okay? I think so. Warner, do you have any objections? In an ideal world, there should be some kind of BUS_UNIDENTIFY method which a driver could use to delete the devices it created in BUS_IDENTIFY. From guido at gvr.org Thu Mar 18 02:21:16 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 02:21:30 2004 Subject: ppbus probe problem In-Reply-To: <200403181012.43455.dfr@nlsystems.com> References: <20040318080230.GA87270@gvr.gvr.org> <20040318100553.GA88901@gvr.gvr.org> <200403181012.43455.dfr@nlsystems.com> Message-ID: <20040318102116.GA89179@gvr.gvr.org> On Thu, Mar 18, 2004 at 10:12:43AM +0000, Doug Rabson wrote: > On Thursday 18 March 2004 10:05, Guido van Rooij wrote: > > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > > > I would use something like: > > > > > > static void > > > vpo_identify(driver_t *driver, device_t parent) > > > { > > > device_t dev; > > > > > > dev = device_find_child(parent, "vpo", 0); > > > if (!dev) > > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > > > } > > > > So I'll update all of the ppbus drivers that way. Okay? > > I think so. Warner, do you have any objections? > > In an ideal world, there should be some kind of BUS_UNIDENTIFY method > which a driver could use to delete the devices it created in > BUS_IDENTIFY. To me, that seems cleaner. The above doesn't work when a new device is added to the system between the load and unload of the driver in question. At least that's how I understand it. -Guido From guido at gvr.org Thu Mar 18 02:21:16 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 02:21:30 2004 Subject: ppbus probe problem In-Reply-To: <200403181012.43455.dfr@nlsystems.com> References: <20040318080230.GA87270@gvr.gvr.org> <20040318100553.GA88901@gvr.gvr.org> <200403181012.43455.dfr@nlsystems.com> Message-ID: <20040318102116.GA89179@gvr.gvr.org> On Thu, Mar 18, 2004 at 10:12:43AM +0000, Doug Rabson wrote: > On Thursday 18 March 2004 10:05, Guido van Rooij wrote: > > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > > > I would use something like: > > > > > > static void > > > vpo_identify(driver_t *driver, device_t parent) > > > { > > > device_t dev; > > > > > > dev = device_find_child(parent, "vpo", 0); > > > if (!dev) > > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > > > } > > > > So I'll update all of the ppbus drivers that way. Okay? > > I think so. Warner, do you have any objections? > > In an ideal world, there should be some kind of BUS_UNIDENTIFY method > which a driver could use to delete the devices it created in > BUS_IDENTIFY. To me, that seems cleaner. The above doesn't work when a new device is added to the system between the load and unload of the driver in question. At least that's how I understand it. -Guido From imp at bsdimp.com Thu Mar 18 06:10:54 2004 From: imp at bsdimp.com (M. Warner Losh) Date: Thu Mar 18 06:11:10 2004 Subject: ppbus probe problem In-Reply-To: <200403181012.43455.dfr@nlsystems.com> References: <200403180913.33873.dfr@nlsystems.com> <20040318100553.GA88901@gvr.gvr.org> <200403181012.43455.dfr@nlsystems.com> Message-ID: <20040318.221110.109506333.imp@bsdimp.com> In message: <200403181012.43455.dfr@nlsystems.com> Doug Rabson writes: : On Thursday 18 March 2004 10:05, Guido van Rooij wrote: : > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: : > > I would use something like: : > > : > > static void : > > vpo_identify(driver_t *driver, device_t parent) : > > { : > > device_t dev; : > > : > > dev = device_find_child(parent, "vpo", 0); : > > if (!dev) : > > BUS_ADD_CHILD(parent, 0, "vpo", -1); : > > } : > : > So I'll update all of the ppbus drivers that way. Okay? : : I think so. Warner, do you have any objections? No. : In an ideal world, there should be some kind of BUS_UNIDENTIFY method : which a driver could use to delete the devices it created in : BUS_IDENTIFY. Or the bus would have a driver deleted routine that got called and it would remove all instances of the devclass attached to it. Warner From imp at bsdimp.com Thu Mar 18 06:10:54 2004 From: imp at bsdimp.com (M. Warner Losh) Date: Thu Mar 18 06:11:11 2004 Subject: ppbus probe problem In-Reply-To: <200403181012.43455.dfr@nlsystems.com> References: <200403180913.33873.dfr@nlsystems.com> <20040318100553.GA88901@gvr.gvr.org> <200403181012.43455.dfr@nlsystems.com> Message-ID: <20040318.221110.109506333.imp@bsdimp.com> In message: <200403181012.43455.dfr@nlsystems.com> Doug Rabson writes: : On Thursday 18 March 2004 10:05, Guido van Rooij wrote: : > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: : > > I would use something like: : > > : > > static void : > > vpo_identify(driver_t *driver, device_t parent) : > > { : > > device_t dev; : > > : > > dev = device_find_child(parent, "vpo", 0); : > > if (!dev) : > > BUS_ADD_CHILD(parent, 0, "vpo", -1); : > > } : > : > So I'll update all of the ppbus drivers that way. Okay? : : I think so. Warner, do you have any objections? No. : In an ideal world, there should be some kind of BUS_UNIDENTIFY method : which a driver could use to delete the devices it created in : BUS_IDENTIFY. Or the bus would have a driver deleted routine that got called and it would remove all instances of the devclass attached to it. Warner From guido at gvr.org Thu Mar 18 06:26:37 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 06:28:14 2004 Subject: ppbus probe problem In-Reply-To: <20040318.221110.109506333.imp@bsdimp.com> References: <200403180913.33873.dfr@nlsystems.com> <200403181012.43455.dfr@nlsystems.com> <20040318.221110.109506333.imp@bsdimp.com> Message-ID: <20040318142637.GA92351@gvr.gvr.org> On Thu, Mar 18, 2004 at 10:11:10PM +0800, M. Warner Losh wrote: > : > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > : > > I would use something like: > : > > > : > > static void > : > > vpo_identify(driver_t *driver, device_t parent) > : > > { > : > > device_t dev; > : > > > : > > dev = device_find_child(parent, "vpo", 0); > : > > if (!dev) > : > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > : > > } > : > > : > So I'll update all of the ppbus drivers that way. Okay? > : > : I think so. Warner, do you have any objections? > > No. > > : In an ideal world, there should be some kind of BUS_UNIDENTIFY method > : which a driver could use to delete the devices it created in > : BUS_IDENTIFY. > > Or the bus would have a driver deleted routine that got called and it > would remove all instances of the devclass attached to it. Ok, I'll commit the changes Doug suggested. Warner: I have a working tw driver. Would you care looking at it? It is ppbus based. -Guido From guido at gvr.org Thu Mar 18 06:26:37 2004 From: guido at gvr.org (Guido van Rooij) Date: Thu Mar 18 06:28:14 2004 Subject: ppbus probe problem In-Reply-To: <20040318.221110.109506333.imp@bsdimp.com> References: <200403180913.33873.dfr@nlsystems.com> <200403181012.43455.dfr@nlsystems.com> <20040318.221110.109506333.imp@bsdimp.com> Message-ID: <20040318142637.GA92351@gvr.gvr.org> On Thu, Mar 18, 2004 at 10:11:10PM +0800, M. Warner Losh wrote: > : > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: > : > > I would use something like: > : > > > : > > static void > : > > vpo_identify(driver_t *driver, device_t parent) > : > > { > : > > device_t dev; > : > > > : > > dev = device_find_child(parent, "vpo", 0); > : > > if (!dev) > : > > BUS_ADD_CHILD(parent, 0, "vpo", -1); > : > > } > : > > : > So I'll update all of the ppbus drivers that way. Okay? > : > : I think so. Warner, do you have any objections? > > No. > > : In an ideal world, there should be some kind of BUS_UNIDENTIFY method > : which a driver could use to delete the devices it created in > : BUS_IDENTIFY. > > Or the bus would have a driver deleted routine that got called and it > would remove all instances of the devclass attached to it. Ok, I'll commit the changes Doug suggested. Warner: I have a working tw driver. Would you care looking at it? It is ppbus based. -Guido From imp at bsdimp.com Thu Mar 18 06:34:51 2004 From: imp at bsdimp.com (M. Warner Losh) Date: Thu Mar 18 06:37:41 2004 Subject: ppbus probe problem In-Reply-To: <20040318142637.GA92351@gvr.gvr.org> References: <200403181012.43455.dfr@nlsystems.com> <20040318.221110.109506333.imp@bsdimp.com> <20040318142637.GA92351@gvr.gvr.org> Message-ID: <20040318.223507.19258520.imp@bsdimp.com> In message: <20040318142637.GA92351@gvr.gvr.org> Guido van Rooij writes: : On Thu, Mar 18, 2004 at 10:11:10PM +0800, M. Warner Losh wrote: : > : > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: : > : > > I would use something like: : > : > > : > : > > static void : > : > > vpo_identify(driver_t *driver, device_t parent) : > : > > { : > : > > device_t dev; : > : > > : > : > > dev = device_find_child(parent, "vpo", 0); : > : > > if (!dev) : > : > > BUS_ADD_CHILD(parent, 0, "vpo", -1); : > : > > } : > : > : > : > So I'll update all of the ppbus drivers that way. Okay? : > : : > : I think so. Warner, do you have any objections? : > : > No. : > : > : In an ideal world, there should be some kind of BUS_UNIDENTIFY method : > : which a driver could use to delete the devices it created in : > : BUS_IDENTIFY. : > : > Or the bus would have a driver deleted routine that got called and it : > would remove all instances of the devclass attached to it. : : Ok, I'll commit the changes Doug suggested. : : Warner: I have a working tw driver. Would you care looking at it? : It is ppbus based. I saw it, but didn't have a chance to look at it since I'm traveling in Taiwan this week. Warner From imp at bsdimp.com Thu Mar 18 06:34:51 2004 From: imp at bsdimp.com (M. Warner Losh) Date: Thu Mar 18 06:37:42 2004 Subject: ppbus probe problem In-Reply-To: <20040318142637.GA92351@gvr.gvr.org> References: <200403181012.43455.dfr@nlsystems.com> <20040318.221110.109506333.imp@bsdimp.com> <20040318142637.GA92351@gvr.gvr.org> Message-ID: <20040318.223507.19258520.imp@bsdimp.com> In message: <20040318142637.GA92351@gvr.gvr.org> Guido van Rooij writes: : On Thu, Mar 18, 2004 at 10:11:10PM +0800, M. Warner Losh wrote: : > : > On Thu, Mar 18, 2004 at 09:13:33AM +0000, Doug Rabson wrote: : > : > > I would use something like: : > : > > : > : > > static void : > : > > vpo_identify(driver_t *driver, device_t parent) : > : > > { : > : > > device_t dev; : > : > > : > : > > dev = device_find_child(parent, "vpo", 0); : > : > > if (!dev) : > : > > BUS_ADD_CHILD(parent, 0, "vpo", -1); : > : > > } : > : > : > : > So I'll update all of the ppbus drivers that way. Okay? : > : : > : I think so. Warner, do you have any objections? : > : > No. : > : > : In an ideal world, there should be some kind of BUS_UNIDENTIFY method : > : which a driver could use to delete the devices it created in : > : BUS_IDENTIFY. : > : > Or the bus would have a driver deleted routine that got called and it : > would remove all instances of the devclass attached to it. : : Ok, I'll commit the changes Doug suggested. : : Warner: I have a working tw driver. Would you care looking at it? : It is ppbus based. I saw it, but didn't have a chance to look at it since I'm traveling in Taiwan this week. Warner