From owner-p4-projects@FreeBSD.ORG Tue Sep 29 18:19:43 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C78FB106568B; Tue, 29 Sep 2009 18:19:43 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8BF67106568F for ; Tue, 29 Sep 2009 18:19:43 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2B6EF8FC15 for ; Tue, 29 Sep 2009 18:19:43 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n8TIJhwo013617 for ; Tue, 29 Sep 2009 18:19:43 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n8TIJhm9013615 for perforce@freebsd.org; Tue, 29 Sep 2009 18:19:43 GMT (envelope-from jhb@freebsd.org) Date: Tue, 29 Sep 2009 18:19:43 GMT Message-Id: <200909291819.n8TIJhm9013615@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 169023 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2009 18:19:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=169023 Change 169023 by jhb@jhb_jhbbsd on 2009/09/29 18:19:07 Teach the acpi(4) bus to mark all resources as reserved aside from a few cases: 1) We ignore IRQ resources for PCI link devices completely. These are not real resources, at least not in the way that we want to manage with rman. 2) Do not reserve resources for system resource devices since they are handled specially. Affected files ... .. //depot/projects/multipass/sys/dev/acpica/acpi.c#6 edit Differences ... ==== //depot/projects/multipass/sys/dev/acpica/acpi.c#6 (text+ko) ==== @@ -118,6 +118,8 @@ uintptr_t value); static struct resource_list *acpi_get_rlist(device_t dev, device_t child); static int acpi_sysres_alloc(device_t dev); +static int acpi_set_resource(device_t dev, device_t child, int type, + int rid, u_long start, u_long count); static struct resource *acpi_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); @@ -190,7 +192,7 @@ DEVMETHOD(bus_read_ivar, acpi_read_ivar), DEVMETHOD(bus_write_ivar, acpi_write_ivar), DEVMETHOD(bus_get_resource_list, acpi_get_rlist), - DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_set_resource, acpi_set_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_alloc_resource, acpi_alloc_resource), DEVMETHOD(bus_release_resource, acpi_release_resource), @@ -1114,6 +1116,38 @@ return (0); } +static int +acpi_set_resource(device_t dev, device_t child, int type, int rid, + u_long start, u_long count) +{ + struct acpi_device *ad = device_get_ivars(child); + struct resource_list *rl = &ad->ad_rl; + char *pcilink_ids[] = { "PNP0C0F", NULL }; + char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL }; + u_long end; + + /* Ignore IRQ resources for PCI link devices. */ + if (type == SYS_RES_IRQ && ACPI_ID_PROBE(dev, child, pcilink_ids) != NULL) + return (0); + + /* Add the resource. */ + end = (start + count - 1); + resource_list_add(rl, type, rid, start, end, count); + + /* Don't reserve system resources. */ + if (ACPI_ID_PROBE(dev, child, sysres_ids) != NULL) + return (0); + + /* + * Reserve the resource. + * + * XXX: Ignores failure for now. Failure here is probably a + * BIOS/firmware bug? + */ + resource_list_reserve(rl, dev, child, type, &rid, start, end, count, 0); + return (0); +} + static struct resource * acpi_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) @@ -1246,6 +1280,12 @@ struct resource_list *rl; rl = acpi_get_rlist(bus, child); + if (resource_list_busy(rl, type, rid)) { + device_printf(bus, "delete_resource: Resource still owned by child" + " (type=%d, rid=%d)\n", type, rid); + return; + } + resource_list_unreserve(rl, bus, child, type, rid); resource_list_delete(rl, type, rid); }