From owner-cvs-src@FreeBSD.ORG Tue Apr 15 07:27:55 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5902137B405; Tue, 15 Apr 2003 07:27:55 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id A335F43FBD; Tue, 15 Apr 2003 07:27:51 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h3FERoA7062951; Tue, 15 Apr 2003 08:27:50 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 15 Apr 2003 08:27:27 -0600 (MDT) Message-Id: <20030415.082727.65119004.imp@bsdimp.com> To: mdodd@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <20030414124016.O39446@sasami.jurai.net> References: <200304140945.h3E9jPCe005099@repoman.freebsd.org> <20030414.102923.58074053.imp@bsdimp.com> <20030414124016.O39446@sasami.jurai.net> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: sobomax@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org cc: cvs-src@FreeBSD.org Subject: Re: cvs commit: src/sys/dev/fxp if_fxp.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Apr 2003 14:27:56 -0000 In message: <20030414124016.O39446@sasami.jurai.net> "Matthew N. Dodd" writes: : On Mon, 14 Apr 2003, M. Warner Losh wrote: : > In message: <200304140945.h3E9jPCe005099@repoman.freebsd.org> : > Maxim Sobolev writes: : > : Before attaching device set PCIM_CMD_PORTEN in addition to : > : PCIM_CMD_MEMEN and PCIM_CMD_BUSMASTEREN, becaise some braindead : > : BIOSes (such as one found in my vprmatrix notebook) forget : > : to initialize it properly resulting in attachment failure. : > : > Actually, code like this should be the pci bus, since all driver have : > this issue... : : Likely this could be added to the bus_alloc_resource() path... Doing a : sanity check on requests and then enabling the resource seems like the : correct solution. Yup. Here's the patch I came up with. Care to review? Index: pci.c =================================================================== RCS file: /home/ncvs/src/sys/dev/pci/pci.c,v retrieving revision 1.212 diff -u -r1.212 pci.c --- pci.c 19 Feb 2003 05:47:09 -0000 1.212 +++ pci.c 15 Apr 2003 14:23:03 -0000 @@ -1301,21 +1301,33 @@ * XXX add support here for SYS_RES_IOPORT and SYS_RES_MEMORY */ if (device_get_parent(child) == dev) { - /* - * If the child device doesn't have an interrupt routed - * and is deserving of an interrupt, try to assign it one. - */ - if ((type == SYS_RES_IRQ) && - !PCI_INTERRUPT_VALID(cfg->intline) && - (cfg->intpin != 0)) { - cfg->intline = PCIB_ROUTE_INTERRUPT( - device_get_parent(dev), child, cfg->intpin); - if (PCI_INTERRUPT_VALID(cfg->intline)) { - pci_write_config(child, PCIR_INTLINE, - cfg->intline, 1); - resource_list_add(rl, SYS_RES_IRQ, 0, - cfg->intline, cfg->intline, 1); + switch (type) { + case SYS_RES_IRQ: + /* + * If the child device doesn't have an + * interrupt routed and is deserving of an + * interrupt, try to assign it one. + */ + if (!PCI_INTERRUPT_VALID(cfg->intline) && + (cfg->intpin != 0)) { + cfg->intline = PCIB_ROUTE_INTERRUPT( + device_get_parent(dev), child, cfg->intpin); + if (PCI_INTERRUPT_VALID(cfg->intline)) { + pci_write_config(child, PCIR_INTLINE, + cfg->intline, 1); + resource_list_add(rl, SYS_RES_IRQ, 0, + cfg->intline, cfg->intline, 1); + } } + break; + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + /* + * Enable the I/O mode. We should also be allocating + * resources too. XXX + */ + pci_enable_io_method(dev, child, type); + break; } }