From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 7 16:00:27 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C9CC416A403; Thu, 7 Dec 2006 16:00:27 +0000 (UTC) (envelope-from tbyte@otel.net) Received: from mail.otel.net (gw3.OTEL.net [212.36.8.151]) by mx1.FreeBSD.org (Postfix) with ESMTP id A99C044549; Thu, 7 Dec 2006 15:53:49 +0000 (GMT) (envelope-from tbyte@otel.net) Received: from dragon.otel.net ([212.36.8.135]) by mail.otel.net with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1GsLa1-0006Nr-97; Thu, 07 Dec 2006 17:54:38 +0200 From: Iasen Kostov To: John Baldwin In-Reply-To: <200612061135.55487.jhb@freebsd.org> References: <1164842336.1066.6.camel@WarHeaD.OTEL.net> <200612061135.55487.jhb@freebsd.org> Content-Type: multipart/mixed; boundary="=-JzvqiRaU8sheWlcGbKlB" Date: Thu, 07 Dec 2006 17:54:36 +0200 Message-Id: <1165506876.37590.12.camel@DraGoN.OTEL.net> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2.1 FreeBSD GNOME Team Port Cc: freebsd-hackers@freebsd.org Subject: Re: Driver not unset properly after kldunload X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2006 16:00:27 -0000 --=-JzvqiRaU8sheWlcGbKlB Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, 2006-12-06 at 11:35 -0500, John Baldwin wrote: ... > I don't see why this patch changes things. devclass_delete_device() only > clears dev->unit, dev->devclass, and dev->nameunit. device_set_driver() > doesn't check or clear any of those. In fact, your change does make > device_set_driver() not work at all since the device state will still be > DS_ATTACHED when you call device_set_driver() now. So, I guess your patch > actually makes the device _not_ be detached from the driver. > Forgive me for being so lazy :). I've analized the problem as I should have done the first time and I hope I found the solution. First time I was missleaded by sys/dev/pci/pci_user.c and the way it sets pd_name[] in pci_devinfo struct (You actualy need to use pciconf atleast once after loading the driver) ... It's only set when you use PCIOCGETCONF ioctl on /dev/pci and it only sets it once (which is not very clever) and never unset it. But one can unload the current driver and load another (as in if_nfe, if_nve case) or just unload the driver and pd_name[] will always show the first driver attached on that device. So I hope this new patch is better one. --=-JzvqiRaU8sheWlcGbKlB Content-Disposition: attachment; filename=pci_user.c.diff Content-Type: text/x-patch; name=pci_user.c.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit --- sys/dev/pci/pci_user.c.old Thu Dec 7 02:26:12 2006 +++ sys/dev/pci/pci_user.c Thu Dec 7 02:52:23 2006 @@ -303,14 +303,18 @@ /* Populate pd_name and pd_unit */ name = NULL; - if (dinfo->cfg.dev && dinfo->conf.pd_name[0] == '\0') + if (dinfo->cfg.dev) { name = device_get_name(dinfo->cfg.dev); - if (name) { - strncpy(dinfo->conf.pd_name, name, - sizeof(dinfo->conf.pd_name)); - dinfo->conf.pd_name[PCI_MAXNAMELEN] = 0; - dinfo->conf.pd_unit = - device_get_unit(dinfo->cfg.dev); + if (name) { + strncpy(dinfo->conf.pd_name, name, + sizeof(dinfo->conf.pd_name)); + dinfo->conf.pd_name[PCI_MAXNAMELEN] = 0; + dinfo->conf.pd_unit = + device_get_unit(dinfo->cfg.dev); + } else { + dinfo->conf.pd_name[0] = '\0'; + dinfo->conf.pd_unit = 0; + } } if ((pattern_buf == NULL) || --=-JzvqiRaU8sheWlcGbKlB--