From owner-svn-src-all@FreeBSD.ORG Wed Jun 17 14:00:57 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 687C21065670; Wed, 17 Jun 2009 14:00:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B7868FC23; Wed, 17 Jun 2009 14:00:57 +0000 (UTC) (envelope-from jhb@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 n5HE0v7P077696; Wed, 17 Jun 2009 14:00:57 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5HE0vDC077694; Wed, 17 Jun 2009 14:00:57 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200906171400.n5HE0vDC077694@svn.freebsd.org> From: John Baldwin Date: Wed, 17 Jun 2009 14:00:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194362 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2009 14:00:58 -0000 Author: jhb Date: Wed Jun 17 14:00:56 2009 New Revision: 194362 URL: http://svn.freebsd.org/changeset/base/194362 Log: MFC: Preallocate the four BARs in ALI SATA controllers during the chipinit routine. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-chipset.c stable/7/sys/dev/ath/ath_hal/ (props changed) Modified: stable/7/sys/dev/ata/ata-chipset.c ============================================================================== --- stable/7/sys/dev/ata/ata-chipset.c Wed Jun 17 13:36:08 2009 (r194361) +++ stable/7/sys/dev/ata/ata-chipset.c Wed Jun 17 14:00:56 2009 (r194362) @@ -198,6 +198,9 @@ static int ata_atapi(device_t dev); static int ata_check_80pin(device_t dev, int mode); static int ata_mode2idx(int mode); +struct ali_sata_resources { + struct resource *bars[4]; +}; /* * generic ATA support functions @@ -1094,6 +1097,8 @@ static int ata_ali_chipinit(device_t dev) { struct ata_pci_controller *ctlr = device_get_softc(dev); + struct ali_sata_resources *res; + int i, rid; if (ata_setup_interrupt(dev)) return ENXIO; @@ -1108,6 +1113,22 @@ ata_ali_chipinit(device_t dev) if ((ctlr->chip->chipid == ATA_ALI_5288) && (ata_ahci_chipinit(dev) != ENXIO)) return 0; + + /* Allocate resources for later use by channel attach routines. */ + res = malloc(sizeof(struct ali_sata_resources), M_TEMP, M_WAITOK); + for (i = 0; i < 4; i++) { + rid = PCIR_BAR(i); + res->bars[i] = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, + RF_ACTIVE); + if (res->bars[i] == NULL) { + device_printf(dev, "Failed to allocate BAR %d\n", i); + for (i--; i >=0; i--) + bus_release_resource(dev, SYS_RES_IOPORT, + PCIR_BAR(i), res->bars[i]); + free(res, M_TEMP); + } + } + ctlr->chipset_data = res; break; case ALINEW: @@ -1162,20 +1183,18 @@ ata_ali_sata_allocate(device_t dev) device_t parent = device_get_parent(dev); struct ata_pci_controller *ctlr = device_get_softc(parent); struct ata_channel *ch = device_get_softc(dev); + struct ali_sata_resources *res; struct resource *io = NULL, *ctlio = NULL; int unit01 = (ch->unit & 1), unit10 = (ch->unit & 2); - int i, rid; - - rid = PCIR_BAR(0) + (unit01 ? 8 : 0); - io = bus_alloc_resource_any(parent, SYS_RES_IOPORT, &rid, RF_ACTIVE); - if (!io) - return ENXIO; + int i; - rid = PCIR_BAR(1) + (unit01 ? 8 : 0); - ctlio = bus_alloc_resource_any(parent, SYS_RES_IOPORT, &rid, RF_ACTIVE); - if (!ctlio) { - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); - return ENXIO; + res = ctlr->chipset_data; + if (unit01) { + io = res->bars[2]; + ctlio = res->bars[3]; + } else { + io = res->bars[0]; + ctlio = res->bars[1]; } for (i = ATA_DATA; i <= ATA_COMMAND; i ++) {