From owner-p4-projects@FreeBSD.ORG Thu May 12 12:04:36 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 224D01065670; Thu, 12 May 2011 12:04:36 +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 C0B611065676 for ; Thu, 12 May 2011 12:04:35 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id AEA0F8FC0C for ; Thu, 12 May 2011 12:04:35 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p4CC4Z13027379 for ; Thu, 12 May 2011 12:04:35 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p4CC4ZIU027376 for perforce@freebsd.org; Thu, 12 May 2011 12:04:35 GMT (envelope-from jhb@freebsd.org) Date: Thu, 12 May 2011 12:04:35 GMT Message-Id: <201105121204.p4CC4ZIU027376@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 193005 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2011 12:04:36 -0000 http://p4web.freebsd.org/@@193005?ac=10 Change 193005 by jhb@jhb_fiver on 2011/05/12 12:04:15 Add an adjust resource helper for the host_res API to fail attempts to adjust a resource if the new range would not be contained in a decoded range. Affected files ... .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#18 edit .. //depot/projects/pci/sys/dev/pci/pci_domain.c#11 edit Differences ... ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#18 (text+ko) ==== @@ -90,6 +90,11 @@ device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); +#ifdef NEW_PCIB +static int acpi_pcib_acpi_adjust_resource(device_t dev, + device_t child, int type, struct resource *r, + u_long start, u_long end); +#endif static device_method_t acpi_pcib_acpi_methods[] = { /* Device interface */ @@ -104,7 +109,11 @@ DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar), DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource), +#ifdef NEW_PCIB + DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource), +#else DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), +#endif DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), @@ -559,3 +568,16 @@ count, flags)); #endif } + +#ifdef NEW_PCIB +int +acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type, + struct resource *r, u_long start, u_long end) +{ + struct acpi_hpcib_softc *sc; + + sc = device_get_softc(dev); + return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start, + end)); +} +#endif ==== //depot/projects/pci/sys/dev/pci/pci_domain.c#11 (text+ko) ==== @@ -112,10 +112,10 @@ * This API provides a way to manage this. The bridge drive should * initialize this structure during attach and call * pcib_host_res_decodes() on each resource range it decodes. It can - * then use pcib_host_res_alloc() as a helper routine for - * BUS_ALLOC_RESOURCE(). This API assumes that resources for any - * decoded ranges can be safely allocated from the parent via - * bus_generic_alloc_resource(). + * then use pcib_host_res_alloc() and pcib_host_res_adjust() as helper + * routines for BUS_ALLOC_RESOURCE() and BUS_ADJUST_RESOURCE(). This + * API assumes that resources for any decoded ranges can be safely + * allocated from the parent via bus_generic_alloc_resource(). */ int pcib_host_res_init(device_t pcib, struct pcib_host_resources *hr) @@ -215,3 +215,28 @@ } return (NULL); } + +int +pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, int type, + struct resource *r, u_long start, u_long end) +{ + struct resource_list_entry *rle; + + rle = resource_list_find(&hr->hr_rl, type, 0); + if (rle == NULL) { + /* + * No decoding ranges for this resource type, just pass + * the request up to the parent. + */ + return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r, + start, end)); + } + + /* Only allow adjustments that stay within a decoded range. */ + for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) { + if (rle->start <= start && rle->end >= end) + return (bus_generic_adjust_resource(hr->hr_pcib, dev, + type, r, start, end)); + } + return (ERANGE); +}