From owner-freebsd-bugs@FreeBSD.ORG Mon Dec 11 13:10:13 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5C1EE16A415 for ; Mon, 11 Dec 2006 13:10:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF7C243CA6 for ; Mon, 11 Dec 2006 13:08:55 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kBBDABsK037784 for ; Mon, 11 Dec 2006 13:10:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kBBDABlU037783; Mon, 11 Dec 2006 13:10:11 GMT (envelope-from gnats) Date: Mon, 11 Dec 2006 13:10:11 GMT Message-Id: <200612111310.kBBDABlU037783@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Iasen Kostov Cc: Subject: Re: kern/104777: [kernel] [patch] Driver not unset properly after kldunload X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Iasen Kostov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 13:10:13 -0000 The following reply was made to PR kern/104777; it has been noted by GNATS. From: Iasen Kostov To: bug-followup@FreeBSD.org, tbyte@otel.net Cc: Subject: Re: kern/104777: [kernel] [patch] Driver not unset properly after kldunload Date: Mon, 11 Dec 2006 15:07:19 +0200 --=-1Fy3i/CbiP2cB5LqrocQ Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. --=-1Fy3i/CbiP2cB5LqrocQ 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) || --=-1Fy3i/CbiP2cB5LqrocQ--