From owner-svn-src-head@FreeBSD.ORG Tue Mar 10 12:10:51 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F45F1065704; Tue, 10 Mar 2009 12:10:51 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 181F68FC1E; Tue, 10 Mar 2009 12:10:51 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2ACApot061839; Tue, 10 Mar 2009 12:10:51 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2ACApQ0061838; Tue, 10 Mar 2009 12:10:51 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200903101210.n2ACApQ0061838@svn.freebsd.org> From: Warner Losh Date: Tue, 10 Mar 2009 12:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189619 - head/sys/dev/cardbus X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 12:11:01 -0000 Author: imp Date: Tue Mar 10 12:10:50 2009 New Revision: 189619 URL: http://svn.freebsd.org/changeset/base/189619 Log: When freeing all the resources of the card, it is better to turn off the PORTEN and MEMEN bits in the command register than to zero the bars. Use pci_write_ivar directly instead of a one-line wrapper that adds no value. Track verbosity changes in pci. Remove a stray blank line. Modified: head/sys/dev/cardbus/cardbus.c Modified: head/sys/dev/cardbus/cardbus.c ============================================================================== --- head/sys/dev/cardbus/cardbus.c Tue Mar 10 11:46:41 2009 (r189618) +++ head/sys/dev/cardbus/cardbus.c Tue Mar 10 12:10:50 2009 (r189619) @@ -221,7 +221,6 @@ cardbus_detach_card(device_t cbdev) if (device_get_children(cbdev, &devlist, &numdevs) != 0) return (ENOENT); - if (numdevs == 0) { free(devlist, M_TEMP); return (ENOENT); @@ -269,13 +268,16 @@ cardbus_driver_added(device_t cbdev, dri } if (i > 0 && i == numdevs) POWER_ENABLE_SOCKET(device_get_parent(cbdev), cbdev); - /* XXX Should I wait for power to become good? */ for (i = 0; i < numdevs; i++) { dev = devlist[i]; if (device_get_state(dev) != DS_NOTPRESENT) continue; dinfo = device_get_ivars(dev); pci_print_verbose(&dinfo->pci); + if (bootverbose) + printf("pci%d:%d:%d:%d: reprobing on driver added\n", + dinfo->pci.cfg.domain, dinfo->pci.cfg.bus, + dinfo->pci.cfg.slot, dinfo->pci.cfg.func); pci_cfg_restore(dinfo->pci.cfg.dev, &dinfo->pci); if (device_probe_and_attach(dev) != 0) pci_cfg_save(dev, &dinfo->pci, 1); @@ -287,6 +289,7 @@ static void cardbus_release_all_resources(device_t cbdev, struct cardbus_devinfo *dinfo) { struct resource_list_entry *rle; + device_t dev; /* Free all allocated resources */ STAILQ_FOREACH(rle, &dinfo->pci.resources, link) { @@ -294,15 +297,14 @@ cardbus_release_all_resources(device_t c BUS_RELEASE_RESOURCE(device_get_parent(cbdev), cbdev, rle->type, rle->rid, rle->res); rle->res = NULL; - /* - * zero out config so the card won't acknowledge - * access to the space anymore. XXX doesn't handle - * 64-bit bars. - */ - pci_write_config(dinfo->pci.cfg.dev, rle->rid, 0, 4); } } resource_list_free(&dinfo->pci.resources); + /* turn off the card's decoding now that the resources are done */ + dev = dinfo->pci.cfg.dev; + pci_write_config(dev, PCIR_COMMAND, + pci_read_config(dev, PCIR_COMMAND, 2) & + ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2); } /************************************************************************/ @@ -336,12 +338,6 @@ cardbus_read_ivar(device_t cbdev, device return 0; } -static int -cardbus_write_ivar(device_t cbdev, device_t child, int which, uintptr_t value) -{ - return(pci_write_ivar(cbdev, child, which, value)); -} - static device_method_t cardbus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, cardbus_probe), @@ -352,7 +348,7 @@ static device_method_t cardbus_methods[] /* Bus interface */ DEVMETHOD(bus_read_ivar, cardbus_read_ivar), - DEVMETHOD(bus_write_ivar, cardbus_write_ivar), + DEVMETHOD(bus_write_ivar, pci_write_ivar), DEVMETHOD(bus_driver_added, cardbus_driver_added), /* Card Interface */