Deleted Added
full compact
pci.c (296308) pci.c (296336)
1/*-
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * Copyright (c) 2000, Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000, BSDi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * Copyright (c) 2000, Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000, BSDi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 296308 2016-03-02 09:54:58Z wma $");
30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 296336 2016-03-03 05:07:35Z jhibbits $");
31
32#include "opt_bus.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>
37#include <sys/module.h>
38#include <sys/limits.h>

--- 3048 unchanged lines hidden (view full) ---

3087 }
3088
3089 count = (pci_addr_t)1 << mapsize;
3090 flags = RF_ALIGNMENT_LOG2(mapsize);
3091 if (prefetch)
3092 flags |= RF_PREFETCHABLE;
3093 if (basezero || base == pci_mapbase(testval) || pci_clear_bars) {
3094 start = 0; /* Let the parent decide. */
31
32#include "opt_bus.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>
37#include <sys/module.h>
38#include <sys/limits.h>

--- 3048 unchanged lines hidden (view full) ---

3087 }
3088
3089 count = (pci_addr_t)1 << mapsize;
3090 flags = RF_ALIGNMENT_LOG2(mapsize);
3091 if (prefetch)
3092 flags |= RF_PREFETCHABLE;
3093 if (basezero || base == pci_mapbase(testval) || pci_clear_bars) {
3094 start = 0; /* Let the parent decide. */
3095 end = ~0ul;
3095 end = ~0;
3096 } else {
3097 start = base;
3098 end = base + count - 1;
3099 }
3100 resource_list_add(rl, type, reg, start, end, count);
3101
3102 /*
3103 * Try to allocate the resource for this BAR from our parent
3104 * so that this resource range is already reserved. The
3105 * driver for this device will later inherit this resource in
3106 * pci_alloc_resource().
3107 */
3108 res = resource_list_reserve(rl, bus, dev, type, &reg, start, end, count,
3109 flags);
3096 } else {
3097 start = base;
3098 end = base + count - 1;
3099 }
3100 resource_list_add(rl, type, reg, start, end, count);
3101
3102 /*
3103 * Try to allocate the resource for this BAR from our parent
3104 * so that this resource range is already reserved. The
3105 * driver for this device will later inherit this resource in
3106 * pci_alloc_resource().
3107 */
3108 res = resource_list_reserve(rl, bus, dev, type, &reg, start, end, count,
3109 flags);
3110 if (pci_do_realloc_bars && res == NULL && (start != 0 || end != ~0ul)) {
3110 if (pci_do_realloc_bars && res == NULL && (start != 0 || end != ~0)) {
3111 /*
3112 * If the allocation fails, try to allocate a resource for
3113 * this BAR using any available range. The firmware felt
3114 * it was important enough to assign a resource, so don't
3115 * disable decoding if we can help it.
3116 */
3117 resource_list_delete(rl, type, reg);
3111 /*
3112 * If the allocation fails, try to allocate a resource for
3113 * this BAR using any available range. The firmware felt
3114 * it was important enough to assign a resource, so don't
3115 * disable decoding if we can help it.
3116 */
3117 resource_list_delete(rl, type, reg);
3118 resource_list_add(rl, type, reg, 0, ~0ul, count);
3119 res = resource_list_reserve(rl, bus, dev, type, &reg, 0, ~0ul,
3118 resource_list_add(rl, type, reg, 0, ~0, count);
3119 res = resource_list_reserve(rl, bus, dev, type, ®, 0, ~0,
3120 count, flags);
3121 }
3122 if (res == NULL) {
3123 /*
3124 * If the allocation fails, delete the resource list entry
3125 * and disable decoding for this device.
3126 *
3127 * If the driver requests this resource in the future,

--- 374 unchanged lines hidden (view full) ---

3502
3503 if (bootverbose)
3504 printf("\tsecbus=%d, subbus=%d\n", sec_bus, sub_bus);
3505 if (sec_bus > 0 && sub_bus >= sec_bus) {
3506 start = sec_bus;
3507 end = sub_bus;
3508 count = end - start + 1;
3509
3120 count, flags);
3121 }
3122 if (res == NULL) {
3123 /*
3124 * If the allocation fails, delete the resource list entry
3125 * and disable decoding for this device.
3126 *
3127 * If the driver requests this resource in the future,

--- 374 unchanged lines hidden (view full) ---

3502
3503 if (bootverbose)
3504 printf("\tsecbus=%d, subbus=%d\n", sec_bus, sub_bus);
3505 if (sec_bus > 0 && sub_bus >= sec_bus) {
3506 start = sec_bus;
3507 end = sub_bus;
3508 count = end - start + 1;
3509
3510 resource_list_add(rl, PCI_RES_BUS, 0, 0ul, ~0ul, count);
3510 resource_list_add(rl, PCI_RES_BUS, 0, 0, ~0, count);
3511
3512 /*
3513 * If requested, clear secondary bus registers in
3514 * bridge devices to force a complete renumbering
3515 * rather than reserving the existing range. However,
3516 * preserve the existing size.
3517 */
3518 if (pci_clear_buses)

--- 2252 unchanged lines hidden ---
3511
3512 /*
3513 * If requested, clear secondary bus registers in
3514 * bridge devices to force a complete renumbering
3515 * rather than reserving the existing range. However,
3516 * preserve the existing size.
3517 */
3518 if (pci_clear_buses)

--- 2252 unchanged lines hidden ---