From owner-p4-projects@FreeBSD.ORG Sun Jul 7 01:41:01 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 584CFD9A; Sun, 7 Jul 2013 01:41:01 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1C134D98 for ; Sun, 7 Jul 2013 01:41:01 +0000 (UTC) (envelope-from jonathan@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 0C1EA1C45 for ; Sun, 7 Jul 2013 01:41:01 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r671f0Fv012250 for ; Sun, 7 Jul 2013 01:41:00 GMT (envelope-from jonathan@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r671f0Z2012247 for perforce@freebsd.org; Sun, 7 Jul 2013 01:41:00 GMT (envelope-from jonathan@freebsd.org) Date: Sun, 7 Jul 2013 01:41:00 GMT Message-Id: <201307070141.r671f0Z2012247@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jonathan@freebsd.org using -f From: Jonathan Anderson Subject: PERFORCE change 230769 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 01:41:01 -0000 http://p4web.freebsd.org/@@230769?ac=10 Change 230769 by jonathan@jonathan-on-joe on 2013/07/07 01:40:34 Update libtesla to latest GitHub version. Affected files ... .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/libtesla.h#10 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla-macros.h#6 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla.h#3 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_class.c#6 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_internal.h#8 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#13 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#9 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/libtesla.h#10 (text+ko) ==== @@ -278,8 +278,9 @@ #ifdef _KERNEL #define TESLA_KERN_PRINTF_EV 0x1 -#define TESLA_KERN_DTRACE_EV 0x2 -#define TESLA_KERN_PANIC_EV 0x4 +#define TESLA_KERN_PRINTERR_EV 0x2 +#define TESLA_KERN_DTRACE_EV 0x4 +#define TESLA_KERN_PANIC_EV 0x8 #endif /** @} */ ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla-macros.h#6 (text+ko) ==== @@ -78,6 +78,9 @@ #define strict(...) __tesla_strict(TIGNORE, __VA_ARGS__) #define conditional(...) __tesla_conditional(TIGNORE, __VA_ARGS__) +#define flags(...) __tesla_flags(__VA_ARGS__) +#define bitmask(...) __tesla_mask(__VA_ARGS__) + #define TESLA_NOW __tesla_now ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla.h#3 (text+ko) ==== @@ -99,6 +99,12 @@ /** Function events inside this predicate refer to the caller context. */ struct __tesla_event* __tesla_caller(__tesla_event*, ...); +/** A mask of flags we expect to see. */ +int __tesla_flags(int); + +/** A bitmask that an argument must not exceed. */ +int __tesla_mask(int); + /** * Events named in this predicate should only occur exactly as described. * ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_class.c#6 (text+ko) ==== @@ -170,6 +170,14 @@ } void +tesla_instance_clear(struct tesla_instance *tip) +{ + + bzero(tip, sizeof(*tip)); + assert(!tesla_instance_active(tip)); +} + +void tesla_class_put(struct tesla_class *tsp) { switch (tsp->tc_context) { ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_internal.h#8 (text+ko) ==== @@ -120,13 +120,8 @@ int32_t tesla_instance_clone(struct tesla_class *tclass, const struct tesla_instance *orig, struct tesla_instance **copy); -/** - * This interface releases an instance for reuse; some types of automata will - * prefer tesla_class_reset(), which clears all instances associated with a - * particular tesla_class. - */ -void tesla_instance_destroy(struct tesla_class *tsp, - struct tesla_instance *tip); +/** Zero an instance for re-use. */ +void tesla_instance_clear(struct tesla_instance *tip); /** @@ -161,6 +156,9 @@ /** The instance should be copied to a new instance. */ FORK, + /** The instance should be merged into another instance. */ + JOIN, + /** The instance is irrelevant to the given transitions. */ IGNORE, ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#13 (text+ko) ==== @@ -192,7 +192,7 @@ print_new_instance(struct tesla_class *tcp, struct tesla_instance *tip) { - DEBUG(libtesla.instance.new, "new %td: %tx\n", + DEBUG(libtesla.instance.new, "new %td: %d\n", tip - tcp->tc_instances, tip->ti_state); } @@ -201,7 +201,7 @@ struct tesla_instance *tip, const struct tesla_transition *transp) { - DEBUG(libtesla.state.transition, "update %td: %tx->%tx\n", + DEBUG(libtesla.state.transition, "update %td: %d->%d\n", tip - tcp->tc_instances, transp->from, transp->to); } @@ -211,7 +211,7 @@ const struct tesla_transition *transp) { - DEBUG(libtesla.instance.clone, "clone %td:%tx -> %td:%tx\n", + DEBUG(libtesla.instance.clone, "clone %td:%d -> %td:%d\n", old_instance - tcp->tc_instances, transp->from, new_instance - tcp->tc_instances, transp->to); } @@ -308,6 +308,16 @@ .teh_ignored = print_ignored, }; +static const struct tesla_event_handlers printf_on_failure = { + .teh_init = ev_noop, + .teh_transition = ev_noop, + .teh_clone = ev_noop, + .teh_fail_no_instance = print_no_instance, + .teh_bad_transition = print_bad_transition, + .teh_err = print_error, + .teh_accept = ev_noop, + .teh_ignored = ev_noop, +}; /* * Wrappers that panic on failure: @@ -330,21 +340,12 @@ tesla_panic("TESLA: failure in '%s': bad transition", tcp->tc_name); } -static void -panic_err(struct tesla_class *tcp, int errno, const char *message) -{ - - tesla_panic("TESLA: error in '%s': %s (%d)", tcp->tc_name, message, - errno); -} - static const struct tesla_event_handlers failstop_handlers = { .teh_init = ev_noop, .teh_transition = ev_noop, .teh_clone = ev_noop, .teh_fail_no_instance = panic_no_instance, .teh_bad_transition = panic_bad_transition, - .teh_err = panic_err, .teh_accept = ev_noop, .teh_ignored = ev_noop, }; @@ -356,6 +357,7 @@ */ const static struct tesla_event_handlers* const default_handlers[] = { &printf_handlers, + &printf_on_failure, #if defined(_KERNEL) && defined(KDTRACE_HOOKS) &dtrace_handlers, #endif @@ -365,9 +367,9 @@ static struct tesla_event_metahandler default_event_handlers = { .tem_length = sizeof(default_handlers) / sizeof(*default_handlers), #if defined(_KERNEL) && defined(KDTRACE_HOOKS) - .tem_mask = 0x2, + .tem_mask = TESLA_KERN_DTRACE_EV, #else - .tem_mask = 0x3, + .tem_mask = 0x5, #endif .tem_handlers = default_handlers, }; ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#9 (text+ko) ==== @@ -138,6 +138,23 @@ matched_something = true; break; } + + case JOIN: +#ifndef NDEBUG + { + int target = -1; + for (int j = 0; j < class->tc_limit; j++) { + tesla_instance *t = class->tc_instances + j; + if (t->ti_state == trigger->to) { + target = j; + break; + } + } + assert(target >= 0); + } +#endif + tesla_instance_clear(inst); + break; } if (trigger && (trigger->flags & TESLA_TRANS_CLEANUP)) @@ -230,7 +247,6 @@ if (t->from == inst->ti_state) { assert(inst->ti_key.tk_mask == t->from_mask); - assert(SUBSET(t->from_mask, t->to_mask)); /* * We need to match events against a pattern based on @@ -246,10 +262,20 @@ pattern.tk_mask &= t->from_mask; /* + * Losing information implies a join + * (except during automaton instance cleanup). + */ + if (!SUBSET(t->from_mask, t->to_mask) + && ((t->flags & TESLA_TRANS_CLEANUP) == 0)) { + *trigger = t; + return JOIN; + } + + /* * Does the transition cause key data to be added * to the instance's name? */ - if (t->from_mask == t->to_mask) { + if (SUBSET(t->to_mask, t->from_mask)) { /* * No: just just update the instance * if its (masked) name matches. From owner-p4-projects@FreeBSD.ORG Sun Jul 7 10:20:25 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6D04B818; Sun, 7 Jul 2013 10:20:25 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2E4C5816 for ; Sun, 7 Jul 2013 10:20:25 +0000 (UTC) (envelope-from jonathan@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 209011DBE for ; Sun, 7 Jul 2013 10:20:25 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r67AKOL1085277 for ; Sun, 7 Jul 2013 10:20:25 GMT (envelope-from jonathan@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r67AKOTm085274 for perforce@freebsd.org; Sun, 7 Jul 2013 10:20:24 GMT (envelope-from jonathan@freebsd.org) Date: Sun, 7 Jul 2013 10:20:24 GMT Message-Id: <201307071020.r67AKOTm085274@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jonathan@freebsd.org using -f From: Jonathan Anderson Subject: PERFORCE change 230775 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 10:20:25 -0000 http://p4web.freebsd.org/@@230775?ac=10 Change 230775 by jonathan@jonathan-on-joe on 2013/07/07 10:19:50 Fix signed/unsigned comparison. Affected files ... .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#10 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#10 (text+ko) ==== @@ -143,7 +143,7 @@ #ifndef NDEBUG { int target = -1; - for (int j = 0; j < class->tc_limit; j++) { + for (uint32_t j = 0; j < class->tc_limit; j++) { tesla_instance *t = class->tc_instances + j; if (t->ti_state == trigger->to) { target = j; From owner-p4-projects@FreeBSD.ORG Mon Jul 8 02:20:04 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0A352B1B; Mon, 8 Jul 2013 02:20:04 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BECF1B19 for ; Mon, 8 Jul 2013 02:20:03 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id B0F8C1116 for ; Mon, 8 Jul 2013 02:20:03 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r682K3ia025999 for ; Mon, 8 Jul 2013 02:20:03 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r682K3mb025996 for perforce@freebsd.org; Mon, 8 Jul 2013 02:20:03 GMT (envelope-from jhb@freebsd.org) Date: Mon, 8 Jul 2013 02:20:03 GMT Message-Id: <201307080220.r682K3mb025996@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230855 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 02:20:04 -0000 http://p4web.freebsd.org/@@230855?ac=10 Change 230855 by jhb@jhb_fiver on 2013/07/08 02:19:27 Merge pci_domain.c into pci_subr.c. Affected files ... .. //depot/projects/pci/sys/conf/files#12 edit .. //depot/projects/pci/sys/dev/pci/pci_domain.c#14 delete .. //depot/projects/pci/sys/dev/pci/pci_subr.c#6 edit Differences ... ==== //depot/projects/pci/sys/conf/files#12 (text+ko) ==== @@ -1899,7 +1899,6 @@ dev/pci/ignore_pci.c optional pci dev/pci/isa_pci.c optional pci isa dev/pci/pci.c optional pci -dev/pci/pci_domain.c optional pci new_pcib dev/pci/pci_if.m standard dev/pci/pci_pci.c optional pci dev/pci/pci_subr.c optional pci ==== //depot/projects/pci/sys/dev/pci/pci_subr.c#6 (text+ko) ==== @@ -151,7 +151,7 @@ /* * Some Host-PCI bridge drivers know which resource ranges they can * decode and should only allocate subranges to child PCI devices. - * This API provides a way to manage this. The bridge drive should + * This API provides a way to manage this. The bridge driver 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() and pcib_host_res_adjust() as helper @@ -282,4 +282,100 @@ } return (ERANGE); } + +#ifdef PCI_RES_BUS +struct pci_domain { + int pd_domain; + struct rman pd_bus_rman; + TAILQ_ENTRY(pci_domain) pd_link; +}; + +static TAILQ_HEAD(, pci_domain) domains = TAILQ_HEAD_INITIALIZER(domains); + +/* + * Each PCI domain maintains its own resource manager for PCI bus + * numbers in that domain. Domain objects are created on first use. + * Host to PCI bridge drivers and PCI-PCI bridge drivers should + * allocate their bus ranges from their domain. + */ +static struct pci_domain * +pci_find_domain(int domain) +{ + struct pci_domain *d; + char buf[64]; + int error; + + TAILQ_FOREACH(d, &domains, pd_link) { + if (d->pd_domain == domain) + return (d); + } + + snprintf(buf, sizeof(buf), "PCI domain %d", domain); + d = malloc(sizeof(*d) + strlen(buf) + 1, M_DEVBUF, M_WAITOK | M_ZERO); + d->pd_domain = domain; + d->pd_bus_rman.rm_start = 0; + d->pd_bus_rman.rm_end = PCI_BUSMAX; + d->pd_bus_rman.rm_type = RMAN_ARRAY; + strcpy((char *)(d + 1), buf); + d->pd_bus_rman.rm_descr = (char *)(d + 1); + error = rman_init(&d->pd_bus_rman); + if (error) + panic("Failed to initialize PCI domain %d rman", domain); + TAILQ_INSERT_TAIL(&domains, d, pd_link); + return (d); +} + +struct resource * +pci_domain_alloc_bus(int domain, device_t dev, int *rid, u_long start, + u_long end, u_long count, u_int flags) +{ + struct pci_domain *d; + struct resource *res; + + if (domain < 0 || domain > PCI_DOMAINMAX) + return (NULL); + d = pci_find_domain(domain); + res = rman_reserve_resource(&d->pd_bus_rman, start, end, count, flags, + dev); + if (res == NULL) + return (NULL); + + rman_set_rid(res, *rid); + return (res); +} + +int +pci_domain_adjust_bus(int domain, device_t dev, struct resource *r, + u_long start, u_long end) +{ +#ifdef INVARIANTS + struct pci_domain *d; +#endif + + if (domain < 0 || domain > PCI_DOMAINMAX) + return (EINVAL); +#ifdef INVARIANTS + d = pci_find_domain(domain); + KASSERT(rman_is_region_manager(r, &d->pd_bus_rman), ("bad resource")); +#endif + return (rman_adjust_resource(r, start, end)); +} + +int +pci_domain_release_bus(int domain, device_t dev, int rid, struct resource *r) +{ +#ifdef INVARIANTS + struct pci_domain *d; +#endif + + if (domain < 0 || domain > PCI_DOMAINMAX) + return (EINVAL); +#ifdef INVARIANTS + d = pci_find_domain(domain); + KASSERT(rman_is_region_manager(r, &d->pd_bus_rman), ("bad resource")); +#endif + return (rman_release_resource(r)); +} +#endif /* PCI_RES_BUS */ + #endif /* NEW_PCIB */ From owner-p4-projects@FreeBSD.ORG Tue Jul 9 03:12:19 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E6207956; Tue, 9 Jul 2013 03:12:18 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A9B33954 for ; Tue, 9 Jul 2013 03:12:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 8B763129C for ; Tue, 9 Jul 2013 03:12:18 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r693CIuF021158 for ; Tue, 9 Jul 2013 03:12:18 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r693CIvh021155 for perforce@freebsd.org; Tue, 9 Jul 2013 03:12:18 GMT (envelope-from jhb@freebsd.org) Date: Tue, 9 Jul 2013 03:12:18 GMT Message-Id: <201307090312.r693CIvh021155@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230880 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 03:12:19 -0000 http://p4web.freebsd.org/@@230880?ac=10 Change 230880 by jhb@jhb_pipkin on 2013/07/09 03:11:51 Compile, but doesn't really work yet. Affected files ... .. //depot/projects/pci/sys/amd64/include/resource.h#5 edit .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#33 edit .. //depot/projects/pci/sys/dev/pci/pci_private.h#16 edit .. //depot/projects/pci/sys/dev/pci/pci_subr.c#7 edit .. //depot/projects/pci/sys/dev/pci/pcib_private.h#23 edit .. //depot/projects/pci/sys/i386/include/resource.h#3 edit .. //depot/projects/pci/sys/x86/x86/nexus.c#12 edit Differences ... ==== //depot/projects/pci/sys/amd64/include/resource.h#5 (text+ko) ==== @@ -41,7 +41,7 @@ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ #ifdef NEW_PCIB -//#define PCI_RES_BUS 5 /* PCI bus numbers */ +#define PCI_RES_BUS 5 /* PCI bus numbers */ #endif #endif /* !_MACHINE_RESOURCE_H_ */ ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#33 (text+ko) ==== @@ -44,6 +44,7 @@ #include #include +#include #include #include #include "pcib_if.h" @@ -271,7 +272,21 @@ } #endif +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) static int +first_decoded_bus(struct acpi_hpcib_softc *sc, u_long *startp) +{ + struct resource_list_entry *rle; + + rle = resource_list_find(&sc->ap_host_res.hr_rl, PCI_RES_BUS, 0); + if (rle == NULL) + return (ENXIO); + *startp = rle->start; + return (0); +} +#endif + +static int acpi_pcib_acpi_attach(device_t dev) { struct acpi_hpcib_softc *sc; @@ -280,7 +295,7 @@ u_int slot, func, busok; #if defined(NEW_PCIB) && defined(PCI_RES_BUS) struct resource *bus_res; - u_long start, end; + u_long start; int rid; #endif uint8_t busno; @@ -405,8 +420,7 @@ * If we have a region of bus numbers, use the first * number for our bus. */ - if (rman_first_free_region(&sc->ap_host_res.hr_bus_rman, &start, - &end) == 0) + if (first_decoded_bus(sc, &start) == 0) sc->ap_bus = start; else { rid = 0; @@ -422,8 +436,7 @@ } } else { #ifdef INVARIANTS - if (rman_first_free_region(&sc->ap_host_res.hr_bus_rman, &start, - &end) == 0) + if (first_decoded_bus(sc, &start) == 0) KASSERT(start == sc->ap_bus, ("bus number mismatch")); #endif } ==== //depot/projects/pci/sys/dev/pci/pci_private.h#16 (text+ko) ==== @@ -132,13 +132,4 @@ */ void pci_cfg_save(device_t, struct pci_devinfo *, int); -#ifdef PCI_RES_BUS -struct resource *pci_domain_alloc_bus(int domain, device_t dev, int *rid, - u_long start, u_long end, u_long count, u_int flags); -int pci_domain_adjust_bus(int domain, device_t dev, - struct resource *r, u_long start, u_long end); -int pci_domain_release_bus(int domain, device_t dev, int rid, - struct resource *r); -#endif - #endif /* _PCI_PRIVATE_H_ */ ==== //depot/projects/pci/sys/dev/pci/pci_subr.c#7 (text+ko) ==== @@ -35,11 +35,13 @@ #include #include +#include #include #include #include #include +#include #include /* @@ -183,7 +185,11 @@ struct resource_list_entry *rle; int rid; +#ifdef PCI_RES_BUS + if (bootverbose || type == PCI_RES_BUS) +#else if (bootverbose) +#endif device_printf(hr->hr_pcib, "decoding %d %srange %#lx-%#lx\n", type, flags & RF_PREFETCHABLE ? "prefetchable ": "", start, end); @@ -237,7 +243,11 @@ r = bus_generic_alloc_resource(hr->hr_pcib, dev, type, rid, new_start, new_end, count, flags); if (r != NULL) { +#ifdef PCI_RES_BUS + if (bootverbose || type == PCI_RES_BUS) +#else if (bootverbose) +#endif device_printf(hr->hr_pcib, "allocated type %d (%#lx-%#lx) for rid %x of %s\n", type, rman_get_start(r), rman_get_end(r), ==== //depot/projects/pci/sys/dev/pci/pcib_private.h#23 (text+ko) ==== @@ -118,6 +118,14 @@ int host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func, uint8_t *busnum); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) +struct resource *pci_domain_alloc_bus(int domain, device_t dev, int *rid, + u_long start, u_long end, u_long count, u_int flags); +int pci_domain_adjust_bus(int domain, device_t dev, + struct resource *r, u_long start, u_long end); +int pci_domain_release_bus(int domain, device_t dev, int rid, + struct resource *r); +#endif int pcib_attach(device_t dev); void pcib_attach_common(device_t dev); #ifdef NEW_PCIB ==== //depot/projects/pci/sys/i386/include/resource.h#3 (text+ko) ==== @@ -40,5 +40,8 @@ #define SYS_RES_DRQ 2 /* isa dma lines */ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ +#ifdef NEW_PCIB +#define PCI_RES_BUS 5 /* PCI bus numbers */ +#endif #endif /* !_MACHINE_RESOURCE_H_ */ ==== //depot/projects/pci/sys/x86/x86/nexus.c#12 (text+ko) ==== @@ -521,7 +521,7 @@ { #ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) { + if (type == PCI_RES_BUS) return (pci_domain_release_bus(pcib_get_domain(child), child, rid, r)); #endif From owner-p4-projects@FreeBSD.ORG Wed Jul 10 01:30:37 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0054AAAF; Wed, 10 Jul 2013 01:30:36 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B2B22AA9 for ; Wed, 10 Jul 2013 01:30:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 8BDFB1AB5 for ; Wed, 10 Jul 2013 01:30:36 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A1UadX011129 for ; Wed, 10 Jul 2013 01:30:36 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6A1UaRp011126 for perforce@freebsd.org; Wed, 10 Jul 2013 01:30:36 GMT (envelope-from jhb@freebsd.org) Date: Wed, 10 Jul 2013 01:30:36 GMT Message-Id: <201307100130.r6A1UaRp011126@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230945 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 01:30:37 -0000 http://p4web.freebsd.org/@@230945?ac=10 Change 230945 by jhb@jhb_pippin on 2013/07/10 01:30:20 Whack at this. Affected files ... .. //depot/projects/pci/sys/x86/x86/nexus.c#13 edit Differences ... ==== //depot/projects/pci/sys/x86/x86/nexus.c#13 (text+ko) ==== @@ -372,13 +372,28 @@ struct rman *rm; int needactivate = flags & RF_ACTIVE; +#ifdef PCI_RES_BUS + if (type == PCI_RES_BUS) { + /* + * PCI bus number resources are allocated from a + * specific PCI domain. The child device must be a + * 'pcib' device which implements the pcib ivars. We + * depend on that to determine which PCI domain to + * allocate from. + */ + return (pci_domain_alloc_bus(pcib_get_domain(child), child, rid, + start, end, count, flags)); + } +#endif + /* - * If this is an allocation of the "default" range for a given RID, and - * we know what the resources for this device are (ie. they aren't maintained - * by a child bus), then work out the start/end values. + * If this is an allocation of the "default" range for a given + * RID, and we know what the resources for this device are + * (ie. they aren't maintained by a child bus), then work out + * the start/end values. */ if ((start == 0UL) && (end == ~0UL) && (count == 1)) { - if (ndev == NULL) + if (device_get_parent(child) != bus || ndev == NULL) return(NULL); rle = resource_list_find(&ndev->nx_resources, type, *rid); if (rle == NULL) @@ -388,23 +403,6 @@ count = rle->count; } -#ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) { - /* - * PCI bus number resources are allocated from a - * specific PCI domain. The child device must be a - * 'pcib' device which implements the pcib ivars. We - * depend on that to determine which PCI domain to - * allocate from. - */ - rv = pci_domain_alloc_bus(pcib_get_domain(child), child, rid, - start, end, count, flags); - if (rv == NULL) - return (NULL); - rman_set_rid(rv, *rid); - return (rv); - } -#endif flags &= ~RF_ACTIVE; rm = nexus_rman(type); if (rm == NULL) From owner-p4-projects@FreeBSD.ORG Wed Jul 10 01:45:54 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 310DA38D; Wed, 10 Jul 2013 01:45:54 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E73AC38B for ; Wed, 10 Jul 2013 01:45:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id D74F41B48 for ; Wed, 10 Jul 2013 01:45:53 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A1jrcU013111 for ; Wed, 10 Jul 2013 01:45:53 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6A1jrqu013108 for perforce@freebsd.org; Wed, 10 Jul 2013 01:45:53 GMT (envelope-from jhb@freebsd.org) Date: Wed, 10 Jul 2013 01:45:53 GMT Message-Id: <201307100145.r6A1jrqu013108@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230947 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 01:45:54 -0000 http://p4web.freebsd.org/@@230947?ac=10 Change 230947 by jhb@jhb_pippin on 2013/07/10 01:45:43 Oops, actually give the per-domain bus rman a range to allocate from. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci_subr.c#8 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci_subr.c#8 (text+ko) ==== @@ -329,6 +329,8 @@ strcpy((char *)(d + 1), buf); d->pd_bus_rman.rm_descr = (char *)(d + 1); error = rman_init(&d->pd_bus_rman); + if (error == 0) + error = rman_manage_region(&d->pd_bus_rman, 0, PCI_BUSMAX); if (error) panic("Failed to initialize PCI domain %d rman", domain); TAILQ_INSERT_TAIL(&domains, d, pd_link); From owner-p4-projects@FreeBSD.ORG Wed Jul 10 03:39:57 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 428B6334; Wed, 10 Jul 2013 03:39:57 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 01AEA332 for ; Wed, 10 Jul 2013 03:39:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id E71A71084 for ; Wed, 10 Jul 2013 03:39:56 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A3du0Z029911 for ; Wed, 10 Jul 2013 03:39:56 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6A3ducW029908 for perforce@freebsd.org; Wed, 10 Jul 2013 03:39:56 GMT (envelope-from jhb@freebsd.org) Date: Wed, 10 Jul 2013 03:39:56 GMT Message-Id: <201307100339.r6A3ducW029908@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230948 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 03:39:57 -0000 http://p4web.freebsd.org/@@230948?ac=10 Change 230948 by jhb@jhb_pippin on 2013/07/10 03:39:28 First cut at updating the PCI-PCI bridge driver to work with PCI_RES_BUS which includes bus renumbering support. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci_pci.c#36 edit .. //depot/projects/pci/sys/dev/pci/pci_subr.c#9 edit .. //depot/projects/pci/sys/dev/pci/pcib_private.h#24 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#36 (text+ko) ==== @@ -529,6 +529,208 @@ } } +#ifdef PCI_RES_BUS +/* + * Allocate a suitable secondary bus for this bridge if needed and + * initialize the resource manager for the secondary bus range. + */ +static void +pcib_setup_secbus(struct pcib_softc *sc) +{ + struct pcib_secbus *sec; + char buf[64]; + int error, rid; + + sec = &sc->bus; + sec->rman.rm_start = 0; + sec->rman.rm_end = PCI_BUSMAX; + sec->rman.rm_type = RMAN_ARRAY; + snprintf(buf, sizeof(buf), "%s bus numbers", + device_get_nameunit(sc->dev)); + sec->rman.rm_descr = strdup(buf, M_DEVBUF); + error = rman_init(&sec->rman); + if (error) + panic("Failed to initialize %s bus number rman", + device_get_nameunit(sc->dev)); + +#if 0 + /* + * XXX: Should we reset subbus to secbus if it is < secbus? + * This would at least preserve the existing secbus if it is + * valid. + */ + if (sc->subbus < sc->secbus) + sc->subbus = sc->secbus; +#endif + + /* + * Allocate a resource for the existing secondary bus number + * range if it is valid. + */ + if (sc->secbus != 0 && sc->subbus >= sc->secbus) { + rid = 0; + sec->res = bus_alloc_resource(sc->dev, PCI_RES_BUS, &rid, + sc->secbus, sc->subbus, sc->subbus - sc->secbus + 1, 0); + if (sec->res == NULL) { + if (bootverbose || 1) + device_printf(sc->dev, + "failed to allocate initial secbus range: %u-%u\n", + sc->secbus, sc->subbus); +#if 0 + /* XXX: Should we clear these on failure? */ + sc->secbus = 0; + sc->subbus = 0; +#endif + } + /* XXX */ + if (sec->res != NULL) + device_printf(sc->dev, + "allocated initial secbus range %lu-%lu\n", + rman_get_start(sec->res), rman_get_end(sec->res)); + } + + /* + * If we don't have a valid resource, allocate a fresh resource + * for just this bus. + * + * XXX: Should we always start with a bus higher than our primary + * side bus number? I'm not sure it is required by the spec but + * it seems sensible. OTOH, the existing rmans in any parent + * PCI-PCI bridges should already enforce this. + */ + if (sec->res == NULL) { + /* + * This doesn't use bus_alloc_resource_any() as the + * count of 1 is explicit. + */ + rid = 0; + sec->res = bus_alloc_resource(sc->dev, PCI_RES_BUS, &rid, 0ul, + ~0ul, 1, 0); + if (sec->res != NULL) { + KASSERT(rman_get_size(sec->res) == 1, + ("more than one bus number")); + if (bootverbose || 1) + device_printf(sc->dev, + "allocated initial secbus %lu\n", + rman_get_start(sec->res)); + sc->secbus = rman_get_start(sec->res); + sc->subbus = rman_get_end(sec->res); + } else + device_printf(sc->dev, + "failed to allocate secondary bus number\n"); + } + + /* + * Add the initial resource to the rman and write updated + * secbus and subbus registers. + */ + if (sec->res != NULL) { + error = rman_manage_region(&sec->rman, rman_get_start(sec->res), + rman_get_end(sec->res)); + if (error) + panic("Failed to add resource to rman"); + } + pci_write_config(sc->dev, PCIR_SECBUS_1, sc->secbus, 1); + pci_write_config(sc->dev, PCIR_SUBBUS_1, sc->subbus, 1); +} + +static struct resource * +pcib_suballoc_bus(struct pcib_softc *sc, device_t child, int *rid, u_long start, + u_long end, u_long count, u_int flags) +{ + struct resource *res; + + res = rman_reserve_resource(&sc->bus.rman, start, end, count, + flags, child); + if (res == NULL) + return (NULL); + + if (bootverbose) + device_printf(sc->dev, + "allocated bus range (%lu-%lu) for rid %d of %s\n", + rman_get_start(res), rman_get_end(res), *rid, + pcib_child_name(child)); + rman_set_rid(res, *rid); + return (res); +} + +/* + * Attempt to grow the secondary bus range. This is much simpler than + * for I/O windows as the range can only be grown by increasing + * subbus. + */ +static int +pcib_grow_subbus(struct pcib_softc *sc, u_long new_end) +{ + int error; + + KASSERT(new_end > rman_get_end(sc->bus.res), + ("attempt to shrink subbus")); + error = bus_adjust_resource(sc->dev, PCI_RES_BUS, sc->bus.res, + rman_get_start(sc->bus.res), new_end); + if (error) + return (error); + if (bootverbose || 1) + device_printf(sc->dev, "grew bus range to %lu-%lu\n", + rman_get_start(sc->bus.res), rman_get_end(sc->bus.res)); + sc->subbus = rman_get_end(sc->bus.res); + pci_write_config(sc->dev, PCIR_SUBBUS_1, sc->subbus, 1); + return (0); +} + +static struct resource * +pcib_alloc_subbus(struct pcib_softc *sc, device_t child, int *rid, u_long start, + u_long end, u_long count, u_int flags) +{ + struct resource *res; + u_long start_free, end_free; + + /* + * First, see if the request can be satisified by the existing + * bus range. + */ + res = pcib_suballoc_bus(sc, child, rid, start, end, count, flags); + if (res != NULL) + return (res); + + /* + * If this request is for a specific range, first attempt to + * grow the existing resource to accomodate this request. If + * that fails, retry the allocation using an arbitrary range. + */ + if (start + count - 1 == end) { + if (end < sc->subbus && pcib_grow_subbus(sc, end) == 0) { + res = pcib_suballoc_bus(sc, child, rid, start, end, + count, flags); + if (res != NULL) + return (res); + } + + res = pcib_suballoc_bus(sc, child, rid, 0ul, ~0ul, count, flags); + if (res != NULL) + return (res); + } + + /* + * Finally, attempt to grow the existing resource to accomodate + * the request using an arbitrary range. + */ + if (rman_last_free_region(&sc->bus.rman, &start_free, &end_free) != 0 || + end_free != sc->subbus) + start_free = sc->subbus + 1; + if (bootverbose || 1) { + device_printf(sc->dev, + "attempting to grow bus range for %lu buses\n", count); + printf("\tback candidate range: %lu-%lu\n", start_free, + start_free + count - 1); + } + if (pcib_grow_subbus(sc, start_free + count - 1) == 0) + return (pcib_suballoc_bus(sc, child, rid, 0ul, ~0ul, count, + flags)); + return (NULL); +} +#endif + #else /* @@ -830,6 +1032,9 @@ sc->flags |= PCIB_SUBTRACTIVE; #ifdef NEW_PCIB +#ifdef PCI_RES_BUS + pcib_setup_secbus(sc); +#endif pcib_probe_windows(sc); #endif if (bootverbose) { @@ -876,20 +1081,6 @@ } /* - * XXX If the secondary bus number is zero, we should assign a bus number - * since the BIOS hasn't, then initialise the bridge. A simple - * bus_alloc_resource with the a couple of busses seems like the right - * approach, but we don't know what busses the BIOS might have already - * assigned to other bridges on this bus that probe later than we do. - * - * If the subordinate bus number is less than the secondary bus number, - * we should pick a better value. One sensible alternative would be to - * pick 255; the only tradeoff here is that configuration transactions - * would be more widely routed than absolutely necessary. We could - * then do a walk of the tree later and fix it. - */ - - /* * Always enable busmastering on bridges so that transactions * initiated on the secondary bus are passed through to the * primary bus. @@ -1382,6 +1573,11 @@ } switch (type) { +#ifdef PCI_RES_BUS + case PCI_RES_BUS: + return (pcib_alloc_subbus(sc, child, rid, start, end, count, + flags)); +#endif case SYS_RES_IOPORT: r = pcib_suballoc_resource(sc, &sc->io, child, type, rid, start, end, count, flags); ==== //depot/projects/pci/sys/dev/pci/pci_subr.c#9 (text+ko) ==== @@ -320,7 +320,7 @@ return (d); } - snprintf(buf, sizeof(buf), "PCI domain %d", domain); + snprintf(buf, sizeof(buf), "PCI domain %d bus numbers", domain); d = malloc(sizeof(*d) + strlen(buf) + 1, M_DEVBUF, M_WAITOK | M_ZERO); d->pd_domain = domain; d->pd_bus_rman.rm_start = 0; ==== //depot/projects/pci/sys/dev/pci/pcib_private.h#24 (text+ko) ==== @@ -81,6 +81,14 @@ int step; /* log_2 of window granularity */ const char *name; }; + +#ifdef PCI_RES_BUS +struct pcib_secbus { + struct rman rman; + struct resource *res; + const char *name; +}; +#endif #endif /* @@ -101,6 +109,9 @@ struct pcib_window io; /* I/O port window */ struct pcib_window mem; /* memory window */ struct pcib_window pmem; /* prefetchable memory window */ +#ifdef PCI_RES_BUS + struct pcib_secbus bus; /* secondary bus numbers */ +#endif #else pci_addr_t pmembase; /* base address of prefetchable memory */ pci_addr_t pmemlimit; /* topmost address of prefetchable memory */ From owner-p4-projects@FreeBSD.ORG Wed Jul 10 22:39:45 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C35E0DF2; Wed, 10 Jul 2013 22:39:44 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 84F6ADF0 for ; Wed, 10 Jul 2013 22:39:44 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 7524F1F84 for ; Wed, 10 Jul 2013 22:39:44 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AMdisA091085 for ; Wed, 10 Jul 2013 22:39:44 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6AMdiXa091082 for perforce@freebsd.org; Wed, 10 Jul 2013 22:39:44 GMT (envelope-from brooks@freebsd.org) Date: Wed, 10 Jul 2013 22:39:44 GMT Message-Id: <201307102239.r6AMdiXa091082@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 230987 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 22:39:45 -0000 http://p4web.freebsd.org/@@230987?ac=10 Change 230987 by brooks@brooks_zenith on 2013/07/10 22:39:40 Allow kernels with FDT entries for CPUs or threads are aren't present to boot by checking for a properly initalized spin_entry struct. This will simplify configuration managment while we work toward a state where the FDT is built with each bitfile. Affected files ... .. //depot/projects/ctsrd/beribsd/src/sys/mips/beri/beri_mp.c#4 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/sys/mips/beri/beri_mp.c#4 (text+ko) ==== @@ -57,6 +57,8 @@ { phandle_t cpus, cpu; pcell_t reg; + char prop[16]; + struct spin_entry *se; if ((cpus = OF_finddevice("/cpus")) <= 0) { printf("%s: no \"/cpus\" device found in FDT\n", __func__); @@ -76,8 +78,36 @@ if (reg > MAXCPU) { printf("%s: cpu ID too large (%d > %d)\n", __func__, reg, MAXCPU); + continue; } cpu_of_nodes[reg] = cpu; + + if (reg != 0) { + if (OF_getprop(cpu, "enable-method", &prop, + sizeof(prop)) <= 0 && OF_getprop(OF_parent(cpu), + "enable-method", &prop, sizeof(prop)) <= 0) { + printf("%s: CPU %d has no enable-method " + "property\n", __func__, reg); + continue; + } + if (strcmp("spin-table", prop) != 0) { + printf("%s: CPU %d enable-method is '%s' not " + "'spin-table'\n", __func__, reg, prop); + continue; + } + + if (OF_getprop(cpu, "cpu-release-addr", &se, + sizeof(se)) <= 0) { + printf("%s: CPU %d has missing or invalid " + "cpu-release-addr\n", __func__, reg); + continue; + } + if (se->entry_addr != 1) { + printf("%s: CPU %d has uninitalized spin " + "entry\n", __func__, reg); + continue; + } + } CPU_SET(reg, mask); } while ((cpu = OF_peer(cpu)) > 0); @@ -91,7 +121,7 @@ * XXX: panic instead? */ CPU_ZERO(mask); - CPU_SET(1, mask); + CPU_SET(0, mask); } void From owner-p4-projects@FreeBSD.ORG Wed Jul 10 22:58:05 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2BE65482; Wed, 10 Jul 2013 22:58:05 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CB510480 for ; Wed, 10 Jul 2013 22:58:04 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id ACF7E1033 for ; Wed, 10 Jul 2013 22:58:04 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AMw4IK093544 for ; Wed, 10 Jul 2013 22:58:04 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6AMw4ph093541 for perforce@freebsd.org; Wed, 10 Jul 2013 22:58:04 GMT (envelope-from brooks@freebsd.org) Date: Wed, 10 Jul 2013 22:58:04 GMT Message-Id: <201307102258.r6AMw4ph093541@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 230989 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 22:58:05 -0000 http://p4web.freebsd.org/@@230989?ac=10 Change 230989 by brooks@brooks_zenith on 2013/07/10 22:57:08 Now that they will work on regular BERI/CHERI systmes add configuration entries for a second CPU. Affected files ... .. //depot/projects/ctsrd/beribsd/src/sys/boot/fdt/dts/beri-sim.dts#4 edit .. //depot/projects/ctsrd/beribsd/src/sys/boot/fdt/dts/beripad-de4.dts#25 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/sys/boot/fdt/dts/beri-sim.dts#4 (text+ko) ==== @@ -47,9 +47,34 @@ #size-cells = <1>; cpus { + #address-cells = <1>; + #size-cells = <1>; + + /* + * Secondary CPUs all start disabled and use the + * spin-table enable method. cpu-release-addr must be + * specified for each cpu other than cpu@0. Values of + * cpu-release-addr grow down from 0x100000 (kernel). + */ + status = "disabled"; + enable-method = "spin-table"; + cpu@0 { + device-type = "cpu"; compatible = "sri-cambridge,beri"; + + reg = <0>; + status = "okay"; }; + + cpu@1 { + device-type = "cpu"; + compatible = "sri-cambridge,beri"; + + reg = <1>; + // XXX: should we need cached prefix? + cpu-release-addr = <0xffffffff 0x800fffe0>; + }; }; soc { @@ -69,10 +94,24 @@ reg = <0x0 0x4000000>; // 64M at 0x0 }; + beripic: beripic@7f804000 { + compatible = "sri-cambridge,beri-pic"; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + reg= <0x7f804000 0x400 + 0x7f806000 0x10 + 0x7f806080 0x10 + 0x7f806100 0x10>; + interrupts = <0 1 2 3 4>; + hard-interrupt-sources = <64>; + soft-interrupt-sources = <64>; + }; + serial@7f000000 { compatible = "altera,jtag_uart-11_0"; reg = <0x7f000000 0x40>; - interrupts = <0>; + //interrupts = <0>; }; serial@7f001000 { ==== //depot/projects/ctsrd/beribsd/src/sys/boot/fdt/dts/beripad-de4.dts#25 (text+ko) ==== @@ -67,6 +67,15 @@ reg = <0>; status = "okay"; }; + + cpu@1 { + device-type = "cpu"; + compatible = "sri-cambridge,beri"; + + reg = <1>; + // XXX: should we need cached prefix? + cpu-release-addr = <0xffffffff 0x800fffe0>; + } }; soc { @@ -183,26 +192,26 @@ ethernet@7f007000 { compatible = "altera,atse"; - /* MAC, RX+RXC, TX+TXC. */ + // MAC, RX+RXC, TX+TXC. reg = <0x7f007000 0x400 0x7f007500 0x8 0x7f007520 0x20 0x7f007400 0x8 0x7f007420 0x20>; - /* RX, TX */ + // RX, TX interrupts = <1 2>; interrupt-parent = <&beripic>; }; ethernet@7f005000 { compatible = "altera,atse"; - /* MAC, RX+RXC, TX+TXC. */ + // MAC, RX+RXC, TX+TXC. reg = <0x7f005000 0x400 0x7f005500 0x8 0x7f005520 0x20 0x7f005400 0x8 0x7f005420 0x20>; - /* RX, TX */ + // RX, TX interrupts = <11 12>; interrupt-parent = <&beripic>; }; @@ -214,7 +223,6 @@ 0x70177000 0x2000>; }; -/* usb@0x7f100000 { compatible = "philips,isp1761"; reg = <0x7f100000 0x40000 @@ -223,7 +231,6 @@ interrupts = <4 5>; interrupt-parent = <&beripic>; }; -*/ avgen@0x7f009000 { compatible = "sri-cambridge,avgen"; From owner-p4-projects@FreeBSD.ORG Thu Jul 11 01:11:30 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4CCEAC6D; Thu, 11 Jul 2013 01:11:30 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0B31FC6B for ; Thu, 11 Jul 2013 01:11:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id EFECC1728 for ; Thu, 11 Jul 2013 01:11:29 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B1BT1P012199 for ; Thu, 11 Jul 2013 01:11:29 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6B1BTR1012196 for perforce@freebsd.org; Thu, 11 Jul 2013 01:11:29 GMT (envelope-from jhb@freebsd.org) Date: Thu, 11 Jul 2013 01:11:29 GMT Message-Id: <201307110111.r6B1BTR1012196@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230991 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 01:11:30 -0000 http://p4web.freebsd.org/@@230991?ac=10 Change 230991 by jhb@jhb_pipkin on 2013/07/11 01:11:11 Check for an ISA alias before even trying to allocate. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci_pci.c#37 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#37 (text+ko) ==== @@ -220,15 +220,14 @@ */ if ((start & 0x300) != 0) goto alias; - next_alias = (start & ~0xfful) | 0x100; + next_alias = (start & ~0x3fful) | 0x100; if (next_alias <= end) goto alias; return (0); alias: device_printf(sc->dev, - "I/O range %#lx-%#lx overlaps with an ISA alias\n", start, - end); + "I/O range %#lx-%#lx overlaps with an ISA alias\n", start, end); return (1); } @@ -1579,10 +1578,11 @@ flags)); #endif case SYS_RES_IOPORT: + if (pcib_is_isa_range(sc, start, end, count)) + return (NULL); r = pcib_suballoc_resource(sc, &sc->io, child, type, rid, start, end, count, flags); - if (r != NULL || ((sc->flags & PCIB_SUBTRACTIVE) != 0 && - !pcib_is_isa_range(sc, start, end, count))) + if (r != NULL || (sc->flags & PCIB_SUBTRACTIVE) != 0) break; if (pcib_grow_window(sc, &sc->io, type, start, end, count, flags) == 0) From owner-p4-projects@FreeBSD.ORG Thu Jul 11 03:05:33 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 883AF1F7; Thu, 11 Jul 2013 03:05:33 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 493C21F3 for ; Thu, 11 Jul 2013 03:05:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 39FF31CA9 for ; Thu, 11 Jul 2013 03:05:33 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B35Xot029142 for ; Thu, 11 Jul 2013 03:05:33 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6B35XN4029139 for perforce@freebsd.org; Thu, 11 Jul 2013 03:05:33 GMT (envelope-from jhb@freebsd.org) Date: Thu, 11 Jul 2013 03:05:33 GMT Message-Id: <201307110305.r6B35XN4029139@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230994 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 03:05:33 -0000 http://p4web.freebsd.org/@@230994?ac=10 Change 230994 by jhb@jhb_pippin on 2013/07/11 03:04:55 Fix the PCI bus driver to permit immediate child bridges to allocate a single bus number resource. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci.c#42 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci.c#42 (text+ko) ==== @@ -4292,6 +4292,20 @@ rl = &dinfo->resources; cfg = &dinfo->cfg; switch (type) { +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + case PCI_RES_BUS: + /* + * If rid 0 is not already allocated, create a new + * resource list entry. + */ + if (*rid != 0) + return (NULL); + rle = resource_list_find(rl, type, *rid); + if (rle != NULL && rle->res != NULL) + return (NULL); + resource_list_add(rl, type, *rid, start, end, count); + break; +#endif case SYS_RES_IRQ: /* * Can't alloc legacy interrupt once MSI messages have From owner-p4-projects@FreeBSD.ORG Thu Jul 11 03:30:00 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C144C611; Thu, 11 Jul 2013 03:30:00 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 816C260F for ; Thu, 11 Jul 2013 03:30:00 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 596551DC4 for ; Thu, 11 Jul 2013 03:30:00 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B3TxBp032819 for ; Thu, 11 Jul 2013 03:29:59 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6B3Txrh032816 for perforce@freebsd.org; Thu, 11 Jul 2013 03:29:59 GMT (envelope-from jhb@freebsd.org) Date: Thu, 11 Jul 2013 03:29:59 GMT Message-Id: <201307110329.r6B3Txrh032816@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230995 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 03:30:01 -0000 http://p4web.freebsd.org/@@230995?ac=10 Change 230995 by jhb@jhb_pippin on 2013/07/11 03:29:51 - Partial cardbus updates for the bus renumbering bits. - Don't leak PCI bus number resources. Affected files ... .. //depot/projects/pci/sys/dev/cardbus/cardbus.c#8 edit .. //depot/projects/pci/sys/dev/cardbus/cardbusvar.h#3 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb.c#5 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#5 edit .. //depot/projects/pci/sys/dev/pci/pci.c#43 edit Differences ... ==== //depot/projects/pci/sys/dev/cardbus/cardbus.c#8 (text+ko) ==== @@ -96,17 +96,36 @@ cardbus_attach(device_t cbdev) { struct cardbus_softc *sc; +#ifdef PCI_RES_BUS + int rid; +#endif sc = device_get_softc(cbdev); sc->sc_dev = cbdev; +#ifdef PCI_RES_BUS + rid = 0; + sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid, + pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0); + if (sc->sc_bus == NULL) { + device_printf(cbdev, "failed to allocate bus number\n"); + return (ENXIO); + } +#endif return (0); } static int cardbus_detach(device_t cbdev) { +#ifdef PCI_RES_BUS + struct cardbus_softc *sc; +#endif cardbus_detach_card(cbdev); +#ifdef PCI_RES_BUS + sc = device_get_softc(cbdev); + (void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus)); +#endif return (0); } ==== //depot/projects/pci/sys/dev/cardbus/cardbusvar.h#3 (text+ko) ==== @@ -69,6 +69,9 @@ struct cardbus_softc { device_t sc_dev; +#ifdef PCI_RES_BUS + struct resource *sc_bus; +#endif }; /* ==== //depot/projects/pci/sys/dev/pccbb/pccbb.c#5 (text+ko) ==== @@ -1203,6 +1203,9 @@ u_long align; switch (type) { +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + /* XXX: PCI_RES_BUS handling */ +#endif case SYS_RES_IRQ: tmp = rman_get_start(sc->irq_res); if (start > tmp || end < tmp || count != 1) { ==== //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#5 (text+ko) ==== @@ -321,6 +321,9 @@ sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1); sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1); sc->pribus = pcib_get_bus(parent); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + /* XXX: Need something like pci_setup_secbus() here. */ +#endif SLIST_INIT(&sc->rl); cbb_powerstate_d0(brdev); ==== //depot/projects/pci/sys/dev/pci/pci.c#43 (text+ko) ==== @@ -3868,6 +3868,10 @@ pci_printf(&dinfo->cfg, "Device leaked memory resources\n"); if (resource_list_release_active(rl, dev, child, SYS_RES_IOPORT) != 0) pci_printf(&dinfo->cfg, "Device leaked I/O resources\n"); +#ifdef PCI_RES_BUS + if (resource_list_release_active(rl, dev, child, PCI_RES_BUS) != 0) + pci_printf(&dinfo->cfg, "Device leaked PCI bus numbers\n"); +#endif pci_cfg_save(child, dinfo, 1); } From owner-p4-projects@FreeBSD.ORG Thu Jul 11 04:00:34 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0B080D38; Thu, 11 Jul 2013 04:00:34 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C1EC6D36 for ; Thu, 11 Jul 2013 04:00:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id A3BFF1E99 for ; Thu, 11 Jul 2013 04:00:33 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B40XKN037255 for ; Thu, 11 Jul 2013 04:00:33 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6B40XdQ037252 for perforce@freebsd.org; Thu, 11 Jul 2013 04:00:33 GMT (envelope-from jhb@freebsd.org) Date: Thu, 11 Jul 2013 04:00:33 GMT Message-Id: <201307110400.r6B40XdQ037252@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230999 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 04:00:34 -0000 http://p4web.freebsd.org/@@230999?ac=10 Change 230999 by jhb@jhb_pippin on 2013/07/11 04:00:22 Move pci_domain_*() calls out of the x86 nexus and down into the Host-PCI bridge drivers. Trying to use an ivar in the nexus to infer the right domain to allocate from was error-prone. However, each Host-PCI bridge knows which PCI domain/segment it belongs to. Affected files ... .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#34 edit .. //depot/projects/pci/sys/x86/include/legacyvar.h#2 edit .. //depot/projects/pci/sys/x86/pci/pci_bus.c#4 edit .. //depot/projects/pci/sys/x86/x86/mptable_pci.c#18 edit .. //depot/projects/pci/sys/x86/x86/nexus.c#14 edit Differences ... ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#34 (text+ko) ==== @@ -97,6 +97,11 @@ static int acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type, struct resource *r, u_long start, u_long end); +#ifdef PCI_RES_BUS +static int acpi_pcib_acpi_release_resource(device_t dev, + device_t child, int type, int rid, + struct resource *r); +#endif #endif static device_method_t acpi_pcib_acpi_methods[] = { @@ -116,7 +121,11 @@ #else DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), #endif +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + DEVMETHOD(bus_release_resource, acpi_pcib_acpi_release_resource), +#else DEVMETHOD(bus_release_resource, bus_generic_release_resource), +#endif DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), @@ -424,15 +433,16 @@ sc->ap_bus = start; else { rid = 0; - bus_res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0, + bus_res = pci_domain_alloc_bus(sc->ap_segment, dev, &rid, 0, PCI_BUSMAX, 1, 0); if (bus_res == NULL) { - device_printf(dev, "could not allocate bus number\n"); + device_printf(dev, + "could not allocate bus number\n"); pcib_host_res_free(dev, &sc->ap_host_res); return (ENXIO); } sc->ap_bus = rman_get_start(bus_res); - bus_release_resource(dev, PCI_RES_BUS, rid, bus_res); + pci_domain_release_bus(sc->ap_segment, dev, rid, bus_res); } } else { #ifdef INVARIANTS @@ -587,6 +597,11 @@ #ifdef NEW_PCIB sc = device_get_softc(dev); +#ifdef PCI_RES_BUS + if (type == PCI_RES_BUS) + return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, end, + count, flags)); +#endif res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end, count, flags); @@ -615,7 +630,26 @@ struct acpi_hpcib_softc *sc; sc = device_get_softc(dev); +#ifdef PCI_RES_BUS + if (type == PCI_RES_BUS) + return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, + end)); +#endif return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start, end)); } + +#ifdef PCI_RES_BUS +int +acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + struct acpi_hpcib_softc *sc; + + sc = device_get_softc(dev); + if (type == PCI_RES_BUS) + return (pci_domain_release_bus(sc->ap_segment, child, rid, r)); + return (bus_generic_release_resource(dev, child, type, rid, r)); +} +#endif #endif ==== //depot/projects/pci/sys/x86/include/legacyvar.h#2 (text+ko) ==== @@ -57,6 +57,8 @@ uintptr_t value); struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); +int legacy_pcib_release_resource(device_t dev, device_t child, int type, + int rid, struct resource *r); int legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data); ==== //depot/projects/pci/sys/x86/pci/pci_bus.c#4 (text+ko) ==== @@ -597,11 +597,39 @@ u_long start, u_long end, u_long count, u_int flags) { - start = hostb_alloc_start(type, start, end, count); - return (bus_generic_alloc_resource(dev, child, type, rid, start, end, - count, flags)); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) + return (pci_domain_alloc_bus(0, child, rid, start, end, count, + flags)); +#endif + start = hostb_alloc_start(type, start, end, count); + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) +static int +legacy_pcib_adjust_resource(device_t dev, device_t child, int type, + struct resource *r, u_long start, u_long end) +{ + + if (type == PCI_RES_BUS) + return (pci_domain_adjust_bus(0, child, r, start, end)); + return (bus_generic_adjust_resource(dev, child, type, r, start, end)); +} + +int +legacy_pcib_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + + if (type == PCI_RES_BUS) + return (pci_domain_release_bus(0, child, rid, r)); + return (bus_generic_release_resource(dev, child, type, rid, r)); } +#endif + static device_method_t legacy_pcib_methods[] = { /* Device interface */ DEVMETHOD(device_identify, legacy_pcib_identify), @@ -615,8 +643,13 @@ DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + DEVMETHOD(bus_adjust_resource, legacy_pcib_adjust_resource), + DEVMETHOD(bus_release_resource, legacy_pcib_release_resource), +#else DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), +#endif DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), ==== //depot/projects/pci/sys/x86/x86/mptable_pci.c#18 (text+ko) ==== @@ -129,6 +129,11 @@ { struct mptable_hostb_softc *sc; +#ifdef PCI_RES_BUS + if (type == PCI_RES_BUS) + return (pci_domain_alloc_bus(0, child, rid, start, end, count, + flags)); +#endif sc = device_get_softc(dev); if (type == SYS_RES_IOPORT && start + count - 1 == end) { if (mptable_is_isa_range(start, end)) { @@ -165,6 +170,10 @@ { struct mptable_hostb_softc *sc; +#ifdef PCI_RES_BUS + if (type == PCI_RES_BUS) + return (pci_domain_adjust_bus(0, child, r, start, end)); +#endif sc = device_get_softc(dev); return (pcib_host_res_adjust(&sc->sc_host_res, child, type, r, start, end)); @@ -189,7 +198,11 @@ DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), #endif +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + DEVMETHOD(bus_release_resource, legacy_pcib_release_resource), +#else DEVMETHOD(bus_release_resource, bus_generic_release_resource), +#endif DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), ==== //depot/projects/pci/sys/x86/x86/nexus.c#14 (text+ko) ==== @@ -70,11 +70,6 @@ #include #include -#ifdef PCI_RES_BUS -#include -#include -#endif - #ifdef DEV_APIC #include "pcib_if.h" #endif @@ -372,20 +367,6 @@ struct rman *rm; int needactivate = flags & RF_ACTIVE; -#ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) { - /* - * PCI bus number resources are allocated from a - * specific PCI domain. The child device must be a - * 'pcib' device which implements the pcib ivars. We - * depend on that to determine which PCI domain to - * allocate from. - */ - return (pci_domain_alloc_bus(pcib_get_domain(child), child, rid, - start, end, count, flags)); - } -#endif - /* * If this is an allocation of the "default" range for a given * RID, and we know what the resources for this device are @@ -429,11 +410,6 @@ { struct rman *rm; -#ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) - return (pci_domain_adjust_bus(pcib_get_domain(child), child, r, - start, end)); -#endif rm = nexus_rman(type); if (rm == NULL) return (ENXIO); @@ -518,11 +494,6 @@ struct resource *r) { -#ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) - return (pci_domain_release_bus(pcib_get_domain(child), child, - rid, r)); -#endif if (rman_get_flags(r) & RF_ACTIVE) { int error = bus_deactivate_resource(child, type, rid, r); if (error) From owner-p4-projects@FreeBSD.ORG Thu Jul 11 16:23:03 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4F29BD18; Thu, 11 Jul 2013 16:23:03 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0EFF1D16 for ; Thu, 11 Jul 2013 16:23:03 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id E52A21864 for ; Thu, 11 Jul 2013 16:23:02 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BGN2kZ043285 for ; Thu, 11 Jul 2013 16:23:02 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6BGN2xZ043282 for perforce@freebsd.org; Thu, 11 Jul 2013 16:23:02 GMT (envelope-from brooks@freebsd.org) Date: Thu, 11 Jul 2013 16:23:02 GMT Message-Id: <201307111623.r6BGN2xZ043282@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 231031 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 16:23:03 -0000 http://p4web.freebsd.org/@@231031?ac=10 Change 231031 by brooks@brooks_zenith on 2013/07/11 16:22:08 Turn the unused and uncompilable MIPS_DISABLE_L1_CACHE define in cache.c into an option and when set force I- and D-cache line sizes to 0 (the latter part might be better as a tunable). Fix some casts in an #if 0'd bit of code which attempts to disable L1 cache ops when the cache is coherent. Affected files ... .. //depot/projects/ctsrd/beribsd/src/sys/conf/options.mips#13 edit .. //depot/projects/ctsrd/beribsd/src/sys/mips/mips/cache.c#4 edit .. //depot/projects/ctsrd/beribsd/src/sys/mips/mips/cpu.c#5 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/sys/conf/options.mips#13 (text+ko) ==== @@ -69,6 +69,11 @@ MAXMEM opt_global.h # +# Manual override of cache config +# +MIPS_DISABLE_L1_CACHE opt_global.h + +# # Options that control the Cavium Simple Executive. # OCTEON_MODEL opt_cvmx.h ==== //depot/projects/ctsrd/beribsd/src/sys/mips/mips/cache.c#4 (text+ko) ==== @@ -116,11 +116,9 @@ #ifdef MIPS_DISABLE_L1_CACHE case 0: - mips_cache_ops.mco_icache_sync_all = cache_noop; - mips_cache_ops.mco_icache_sync_range = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_icache_sync_range_index = - (void (*)(vaddr_t, vsize_t))cache_noop; + mips_cache_ops.mco_icache_sync_all = (void (*)(void))cache_noop; + mips_cache_ops.mco_icache_sync_range = cache_noop; + mips_cache_ops.mco_icache_sync_range_index = cache_noop; break; #endif default: @@ -193,20 +191,16 @@ #endif #ifdef MIPS_DISABLE_L1_CACHE case 0: - mips_cache_ops.mco_pdcache_wbinv_all = cache_noop; - mips_cache_ops.mco_intern_pdcache_wbinv_all = cache_noop; - mips_cache_ops.mco_pdcache_wbinv_range = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_pdcache_wbinv_range_index = - (void (*)(vaddr_t, vsize_t))cache_noop; + mips_cache_ops.mco_pdcache_wbinv_all = + mips_cache_ops.mco_intern_pdcache_wbinv_all = + (void (*)(void))cache_noop; + mips_cache_ops.mco_pdcache_wbinv_range = cache_noop; + mips_cache_ops.mco_pdcache_wbinv_range_index = cache_noop; mips_cache_ops.mco_intern_pdcache_wbinv_range_index = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_pdcache_inv_range = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_pdcache_wb_range = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_intern_pdcache_wb_range = - (void (*)(vaddr_t, vsize_t))cache_noop; + cache_noop; + mips_cache_ops.mco_pdcache_inv_range = cache_noop; + mips_cache_ops.mco_pdcache_wb_range = cache_noop; + mips_cache_ops.mco_intern_pdcache_wb_range = cache_noop; break; #endif default: @@ -222,26 +216,22 @@ #ifdef CACHE_DEBUG printf(" Dcache is coherent\n"); #endif - mips_cache_ops.mco_pdcache_wbinv_all = cache_noop; - mips_cache_ops.mco_pdcache_wbinv_range = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_pdcache_wbinv_range_index = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_pdcache_inv_range = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_pdcache_wb_range = - (void (*)(vaddr_t, vsize_t))cache_noop; + mips_cache_ops.mco_pdcache_wbinv_all = + (void (*)(void))cache_noop; + mips_cache_ops.mco_pdcache_wbinv_range = cache_noop; + mips_cache_ops.mco_pdcache_wbinv_range_index = cache_noop; + mips_cache_ops.mco_pdcache_inv_range = cache_noop; + mips_cache_ops.mco_pdcache_wb_range = cache_noop; } if (mips_cpu_flags & CPU_MIPS_I_D_CACHE_COHERENT) { #ifdef CACHE_DEBUG printf(" Icache is coherent against Dcache\n"); #endif mips_cache_ops.mco_intern_pdcache_wbinv_all = + (void (*)(void))cache_noop; + mips_cache_ops.mco_intern_pdcache_wbinv_range_index = cache_noop; - mips_cache_ops.mco_intern_pdcache_wbinv_range_index = - (void (*)(vaddr_t, vsize_t))cache_noop; - mips_cache_ops.mco_intern_pdcache_wb_range = - (void (*)(vaddr_t, vsize_t))cache_noop; + mips_cache_ops.mco_intern_pdcache_wb_range = cache_noop; } #endif ==== //depot/projects/ctsrd/beribsd/src/sys/mips/mips/cpu.c#5 (text+ko) ==== @@ -128,6 +128,9 @@ #endif /* L1 instruction cache. */ +#ifdef MIPS_DISABLE_L1_CACHE + cpuinfo->l1.ic_linesize = 0; +#else tmp = (cfg1 & MIPS_CONFIG1_IL_MASK) >> MIPS_CONFIG1_IL_SHIFT; if (tmp != 0) { cpuinfo->l1.ic_linesize = 1 << (tmp + 1); @@ -135,9 +138,13 @@ cpuinfo->l1.ic_nsets = 1 << (((cfg1 & MIPS_CONFIG1_IS_MASK) >> MIPS_CONFIG1_IS_SHIFT) + 6); } +#endif + /* L1 data cache. */ +#ifdef MIPS_DISABLE_L1_CACHE + cpuinfo->l1.dc_linesize = 0; +#else #ifndef CPU_CNMIPS - /* L1 data cache. */ tmp = (cfg1 & MIPS_CONFIG1_DL_MASK) >> MIPS_CONFIG1_DL_SHIFT; if (tmp != 0) { cpuinfo->l1.dc_linesize = 1 << (tmp + 1); @@ -173,6 +180,7 @@ /* All Octeon models use 128 byte line size. */ cpuinfo->l1.dc_linesize = 128; #endif +#endif cpuinfo->l1.ic_size = cpuinfo->l1.ic_linesize * cpuinfo->l1.ic_nsets * cpuinfo->l1.ic_nways; From owner-p4-projects@FreeBSD.ORG Thu Jul 11 19:09:03 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AF4131FD; Thu, 11 Jul 2013 19:09:03 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 715A61FB for ; Thu, 11 Jul 2013 19:09:03 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 6285F1FEF for ; Thu, 11 Jul 2013 19:09:03 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BJ93M7065537 for ; Thu, 11 Jul 2013 19:09:03 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6BJ93fm065534 for perforce@freebsd.org; Thu, 11 Jul 2013 19:09:03 GMT (envelope-from brooks@freebsd.org) Date: Thu, 11 Jul 2013 19:09:03 GMT Message-Id: <201307111909.r6BJ93fm065534@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 231035 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 19:09:03 -0000 http://p4web.freebsd.org/@@231035?ac=10 Change 231035 by brooks@brooks_zenith on 2013/07/11 19:08:55 Run ctfconvert on tesla object files and ctfmerge on insturmented binaries. Affected files ... .. //depot/projects/ctsrd/tesla/src/share/mk/sys.mk#10 edit .. //depot/projects/ctsrd/tesla/src/sys/conf/kern.post.mk#3 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/share/mk/sys.mk#10 (text+ko) ==== @@ -281,6 +281,7 @@ .instrll.instro: tesla.manifest ${LLC} -filetype=obj ${LLCFLAGS} ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} .manifest.dot: ${TESLA} graph ${.IMPSRC} -o ${.TARGET} ==== //depot/projects/ctsrd/tesla/src/sys/conf/kern.post.mk#3 (text+ko) ==== @@ -184,6 +184,9 @@ ${LD} -Bdynamic -T ${LDSCRIPT} ${LDFLAGS} --no-warn-mismatch \ -warn-common -export-dynamic -dynamic-linker /red/herring \ -o ${.TARGET} -X ${INSTROBJS} ${NOT_C_OBJS} vers.o hack.So +.if ${MK_CTF} != "no" + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${INSTROBJS} ${NOT_C_OBJS} vers.o +.endif # This is a hack. BFD "optimizes" away dynamic mode if there are no # dynamic references. We could probably do a '-Bforcedynamic' mode like From owner-p4-projects@FreeBSD.ORG Fri Jul 12 03:08:48 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5DEC1DB1; Fri, 12 Jul 2013 03:08:48 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1A978DAF for ; Fri, 12 Jul 2013 03:08:48 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id EFEA11619 for ; Fri, 12 Jul 2013 03:08:47 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C38lK8034381 for ; Fri, 12 Jul 2013 03:08:47 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6C38lfF034378 for perforce@freebsd.org; Fri, 12 Jul 2013 03:08:47 GMT (envelope-from jhb@freebsd.org) Date: Fri, 12 Jul 2013 03:08:47 GMT Message-Id: <201307120308.r6C38lfF034378@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 231063 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 03:08:48 -0000 http://p4web.freebsd.org/@@231063?ac=10 Change 231063 by jhb@jhb_pippin on 2013/07/12 03:07:59 Genericize the bus management code in the PCI-PCI driver so it can be used in the PCI-Cardbus driver. Not tested, but does compile. Affected files ... .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_pci.c#6 edit .. //depot/projects/pci/sys/dev/cardbus/cardbus.c#9 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb.c#6 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb_isa.c#4 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#6 edit .. //depot/projects/pci/sys/dev/pccbb/pccbbvar.h#3 edit .. //depot/projects/pci/sys/dev/pci/pci_pci.c#38 edit .. //depot/projects/pci/sys/dev/pci/pcib_private.h#25 edit .. //depot/projects/pci/sys/sparc64/pci/apb.c#6 edit Differences ... ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_pci.c#6 (text+ko) ==== @@ -120,7 +120,7 @@ pcib_attach_common(dev); sc = device_get_softc(dev); sc->ap_handle = acpi_get_handle(dev); - return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_pcibsc.secbus)); + return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_pcibsc.bus.sec)); } static int ==== //depot/projects/pci/sys/dev/cardbus/cardbus.c#9 (text+ko) ==== @@ -124,7 +124,7 @@ cardbus_detach_card(cbdev); #ifdef PCI_RES_BUS sc = device_get_softc(cbdev); - (void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus)); + (void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus); #endif return (0); } ==== //depot/projects/pci/sys/dev/pccbb/pccbb.c#6 (text+ko) ==== @@ -97,6 +97,7 @@ #include #include +#include #include #include @@ -1203,9 +1204,6 @@ u_long align; switch (type) { -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - /* XXX: PCI_RES_BUS handling */ -#endif case SYS_RES_IRQ: tmp = rman_get_start(sc->irq_res); if (start > tmp || end < tmp || count != 1) { @@ -1505,6 +1503,11 @@ { struct cbb_softc *sc = device_get_softc(brdev); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) + return (pcib_alloc_subbus(&sc->bus, child, rid, start, end, + count, flags)); +#endif if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_alloc_resource(brdev, child, type, rid, start, end, count, flags)); @@ -1518,7 +1521,20 @@ struct resource *r) { struct cbb_softc *sc = device_get_softc(brdev); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + int error; + if (type == PCI_RES_BUS) { + if (!rman_is_region_manager(r, &sc->bus.rman)) + return (EINVAL); + if (rman_get_flags(r) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, r); + if (error) + return (error); + } + return (rman_release_resource(r)); + } +#endif if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_release_resource(brdev, child, type, rid, r)); @@ -1537,7 +1553,7 @@ *result = sc->domain; return (0); case PCIB_IVAR_BUS: - *result = sc->secbus; + *result = sc->bus.sec; return (0); } return (ENOENT); @@ -1546,14 +1562,12 @@ int cbb_write_ivar(device_t brdev, device_t child, int which, uintptr_t value) { - struct cbb_softc *sc = device_get_softc(brdev); switch (which) { case PCIB_IVAR_DOMAIN: return (EINVAL); case PCIB_IVAR_BUS: - sc->secbus = value; - return (0); + return (EINVAL); } return (ENOENT); } ==== //depot/projects/pci/sys/dev/pccbb/pccbb_isa.c#4 (text+ko) ==== @@ -51,6 +51,9 @@ #include +#include +#include + #include #include ==== //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#6 (text+ko) ==== @@ -93,6 +93,7 @@ #include #include +#include #include #include @@ -303,13 +304,15 @@ static int cbb_pci_attach(device_t brdev) { +#if !(defined(NEW_PCIB) && defined(PCI_RES_BUS)) static int curr_bus_number = 2; /* XXX EVILE BAD (see below) */ + uint32_t pribus; +#endif struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev); struct sysctl_ctx_list *sctx; struct sysctl_oid *soid; int rid; device_t parent; - uint32_t pribus; parent = device_get_parent(brdev); mtx_init(&sc->mtx, device_get_nameunit(brdev), "cbb", MTX_DEF); @@ -318,11 +321,13 @@ sc->cbdev = NULL; sc->exca[0].pccarddev = NULL; sc->domain = pci_get_domain(brdev); - sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1); - sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1); + sc->bus.sec = pci_read_config(brdev, PCIR_SECBUS_2, 1); + sc->bus.sub = pci_read_config(brdev, PCIR_SUBBUS_2, 1); sc->pribus = pcib_get_bus(parent); #if defined(NEW_PCIB) && defined(PCI_RES_BUS) - /* XXX: Need something like pci_setup_secbus() here. */ + sc->bus.sec_reg = PCIR_SECBUS_2; + sc->bus.sub_reg = PCIR_SUBBUS_2; + pcib_setup_secbus(brdev, &sc->bus); #endif SLIST_INIT(&sc->rl); cbb_powerstate_d0(brdev); @@ -355,9 +360,9 @@ SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "pribus", CTLFLAG_RD, &sc->pribus, 0, "Primary bus number"); SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "secbus", - CTLFLAG_RD, &sc->secbus, 0, "Secondary bus number"); + CTLFLAG_RD, &sc->bus.sec, 0, "Secondary bus number"); SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus", - CTLFLAG_RD, &sc->subbus, 0, "Subordinate bus number"); + CTLFLAG_RD, &sc->bus.sub, 0, "Subordinate bus number"); #if 0 SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "memory", CTLFLAG_RD, &sc->subbus, 0, "Memory window open"); @@ -369,15 +374,16 @@ CTLFLAG_RD, &sc->subbus, 0, "io range 2 open"); #endif +#if !(defined(NEW_PCIB) && defined(PCI_RES_BUS)) /* * This is a gross hack. We should be scanning the entire pci * tree, assigning bus numbers in a way such that we (1) can * reserve 1 extra bus just in case and (2) all sub busses * are in an appropriate range. */ - DEVPRINTF((brdev, "Secondary bus is %d\n", sc->secbus)); + DEVPRINTF((brdev, "Secondary bus is %d\n", sc->bus.sec)); pribus = pci_read_config(brdev, PCIR_PRIBUS_2, 1); - if (sc->secbus == 0 || sc->pribus != pribus) { + if (sc->bus.sec == 0 || sc->pribus != pribus) { if (curr_bus_number <= sc->pribus) curr_bus_number = sc->pribus + 1; if (pribus != sc->pribus) { @@ -385,13 +391,14 @@ sc->pribus)); pci_write_config(brdev, PCIR_PRIBUS_2, sc->pribus, 1); } - sc->secbus = curr_bus_number++; - sc->subbus = curr_bus_number++; + sc->bus.sec = curr_bus_number++; + sc->bus.sub = curr_bus_number++; DEVPRINTF((brdev, "Secondary bus set to %d subbus %d\n", - sc->secbus, sc->subbus)); - pci_write_config(brdev, PCIR_SECBUS_2, sc->secbus, 1); - pci_write_config(brdev, PCIR_SUBBUS_2, sc->subbus, 1); + sc->bus.sec, sc->bus.sub)); + pci_write_config(brdev, PCIR_SECBUS_2, sc->bus.sec, 1); + pci_write_config(brdev, PCIR_SUBBUS_2, sc->bus.sub, 1); } +#endif /* attach children */ sc->cbdev = device_add_child(brdev, "cardbus", -1); @@ -470,8 +477,8 @@ /* Restore bus configuration */ pci_write_config(sc->dev, PCIR_PRIBUS_2, sc->pribus, 1); - pci_write_config(sc->dev, PCIR_SECBUS_2, sc->secbus, 1); - pci_write_config(sc->dev, PCIR_SUBBUS_2, sc->subbus, 1); + pci_write_config(sc->dev, PCIR_SECBUS_2, sc->bus.sec, 1); + pci_write_config(sc->dev, PCIR_SUBBUS_2, sc->bus.sub, 1); /* Enable memory access */ PCI_MASK_CONFIG(sc->dev, PCIR_COMMAND, @@ -789,6 +796,23 @@ return retval; } +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) +static int +cbb_pci_adjust_resource(device_t bus, device_t child, int type, + struct resource *r, u_long start, u_long end) +{ + struct cbb_softc *sc; + + sc = device_get_softc(bus); + if (type == PCI_RES_BUS) { + if (!rman_is_region_manager(r, &sc->bus.rman)) + return (EINVAL); + return (rman_adjust_resource(r, start, end)); + } + return (bus_generic_adjust_resource(bus, child, type, r, start, end)); +} +#endif + /************************************************************************/ /* PCI compat methods */ /************************************************************************/ @@ -833,6 +857,9 @@ DEVMETHOD(bus_read_ivar, cbb_read_ivar), DEVMETHOD(bus_write_ivar, cbb_write_ivar), DEVMETHOD(bus_alloc_resource, cbb_alloc_resource), +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + DEVMETHOD(bus_adjust_resource, cbb_pci_adjust_resource), +#endif DEVMETHOD(bus_release_resource, cbb_release_resource), DEVMETHOD(bus_activate_resource, cbb_activate_resource), DEVMETHOD(bus_deactivate_resource, cbb_deactivate_resource), ==== //depot/projects/pci/sys/dev/pccbb/pccbbvar.h#3 (text+ko) ==== @@ -64,8 +64,7 @@ bus_space_handle_t bsh; uint32_t domain; unsigned int pribus; - unsigned int secbus; - unsigned int subbus; + struct pcib_secbus bus; struct mtx mtx; int cardok; u_int32_t flags; ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#38 (text+ko) ==== @@ -119,6 +119,10 @@ { switch (type) { +#ifdef PCI_RES_BUS + case PCI_RES_BUS: + return (rman_is_region_manager(r, &sc->bus.rman)); +#endif case SYS_RES_IOPORT: return (rman_is_region_manager(r, &sc->io.rman)); case SYS_RES_MEMORY: @@ -533,24 +537,22 @@ * Allocate a suitable secondary bus for this bridge if needed and * initialize the resource manager for the secondary bus range. */ -static void -pcib_setup_secbus(struct pcib_softc *sc) +void +pcib_setup_secbus(device_t dev, struct pcib_secbus *bus) { - struct pcib_secbus *sec; char buf[64]; int error, rid; - sec = &sc->bus; - sec->rman.rm_start = 0; - sec->rman.rm_end = PCI_BUSMAX; - sec->rman.rm_type = RMAN_ARRAY; - snprintf(buf, sizeof(buf), "%s bus numbers", - device_get_nameunit(sc->dev)); - sec->rman.rm_descr = strdup(buf, M_DEVBUF); - error = rman_init(&sec->rman); + bus->dev = dev; + bus->rman.rm_start = 0; + bus->rman.rm_end = PCI_BUSMAX; + bus->rman.rm_type = RMAN_ARRAY; + snprintf(buf, sizeof(buf), "%s bus numbers", device_get_nameunit(dev)); + bus->rman.rm_descr = strdup(buf, M_DEVBUF); + error = rman_init(&bus->rman); if (error) panic("Failed to initialize %s bus number rman", - device_get_nameunit(sc->dev)); + device_get_nameunit(dev)); #if 0 /* @@ -558,34 +560,34 @@ * This would at least preserve the existing secbus if it is * valid. */ - if (sc->subbus < sc->secbus) - sc->subbus = sc->secbus; + if (bus->sub < bus->sec) + bus->sub = bus->sec; #endif /* * Allocate a resource for the existing secondary bus number * range if it is valid. */ - if (sc->secbus != 0 && sc->subbus >= sc->secbus) { + if (bus->sec != 0 && bus->sub >= bus->sec) { rid = 0; - sec->res = bus_alloc_resource(sc->dev, PCI_RES_BUS, &rid, - sc->secbus, sc->subbus, sc->subbus - sc->secbus + 1, 0); - if (sec->res == NULL) { + bus->res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, bus->sec, + bus->sub, bus->sub - bus->sec + 1, 0); + if (bus->res == NULL) { if (bootverbose || 1) - device_printf(sc->dev, + device_printf(dev, "failed to allocate initial secbus range: %u-%u\n", - sc->secbus, sc->subbus); + bus->sec, bus->sub); #if 0 /* XXX: Should we clear these on failure? */ - sc->secbus = 0; - sc->subbus = 0; + bus->sec = 0; + bus->sub = 0; #endif } /* XXX */ - if (sec->res != NULL) - device_printf(sc->dev, + if (bus->res != NULL) + device_printf(dev, "allocated initial secbus range %lu-%lu\n", - rman_get_start(sec->res), rman_get_end(sec->res)); + rman_get_start(bus->res), rman_get_end(bus->res)); } /* @@ -597,25 +599,25 @@ * it seems sensible. OTOH, the existing rmans in any parent * PCI-PCI bridges should already enforce this. */ - if (sec->res == NULL) { + if (bus->res == NULL) { /* * This doesn't use bus_alloc_resource_any() as the * count of 1 is explicit. */ rid = 0; - sec->res = bus_alloc_resource(sc->dev, PCI_RES_BUS, &rid, 0ul, - ~0ul, 1, 0); - if (sec->res != NULL) { - KASSERT(rman_get_size(sec->res) == 1, + bus->res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0ul, ~0ul, + 1, 0); + if (bus->res != NULL) { + KASSERT(rman_get_size(bus->res) == 1, ("more than one bus number")); if (bootverbose || 1) - device_printf(sc->dev, + device_printf(bus->dev, "allocated initial secbus %lu\n", - rman_get_start(sec->res)); - sc->secbus = rman_get_start(sec->res); - sc->subbus = rman_get_end(sec->res); + rman_get_start(bus->res)); + bus->sec = rman_get_start(bus->res); + bus->sub = rman_get_end(bus->res); } else - device_printf(sc->dev, + device_printf(bus->dev, "failed to allocate secondary bus number\n"); } @@ -623,29 +625,28 @@ * Add the initial resource to the rman and write updated * secbus and subbus registers. */ - if (sec->res != NULL) { - error = rman_manage_region(&sec->rman, rman_get_start(sec->res), - rman_get_end(sec->res)); + if (bus->res != NULL) { + error = rman_manage_region(&bus->rman, rman_get_start(bus->res), + rman_get_end(bus->res)); if (error) panic("Failed to add resource to rman"); } - pci_write_config(sc->dev, PCIR_SECBUS_1, sc->secbus, 1); - pci_write_config(sc->dev, PCIR_SUBBUS_1, sc->subbus, 1); + pci_write_config(dev, bus->sec_reg, bus->sec, 1); + pci_write_config(dev, bus->sub_reg, bus->sub, 1); } static struct resource * -pcib_suballoc_bus(struct pcib_softc *sc, device_t child, int *rid, u_long start, - u_long end, u_long count, u_int flags) +pcib_suballoc_bus(struct pcib_secbus *bus, device_t child, int *rid, + u_long start, u_long end, u_long count, u_int flags) { struct resource *res; - res = rman_reserve_resource(&sc->bus.rman, start, end, count, - flags, child); + res = rman_reserve_resource(&bus->rman, start, end, count, flags, child); if (res == NULL) return (NULL); if (bootverbose) - device_printf(sc->dev, + device_printf(bus->dev, "allocated bus range (%lu-%lu) for rid %d of %s\n", rman_get_start(res), rman_get_end(res), *rid, pcib_child_name(child)); @@ -659,72 +660,72 @@ * subbus. */ static int -pcib_grow_subbus(struct pcib_softc *sc, u_long new_end) +pcib_grow_subbus(struct pcib_secbus *bus, u_long new_end) { + u_long old_end; int error; - KASSERT(new_end > rman_get_end(sc->bus.res), - ("attempt to shrink subbus")); - error = bus_adjust_resource(sc->dev, PCI_RES_BUS, sc->bus.res, - rman_get_start(sc->bus.res), new_end); + old_end = rman_get_end(bus->res); + KASSERT(new_end > old_end, ("attempt to shrink subbus")); + error = bus_adjust_resource(bus->dev, PCI_RES_BUS, bus->res, + rman_get_start(bus->res), new_end); if (error) return (error); if (bootverbose || 1) - device_printf(sc->dev, "grew bus range to %lu-%lu\n", - rman_get_start(sc->bus.res), rman_get_end(sc->bus.res)); - sc->subbus = rman_get_end(sc->bus.res); - pci_write_config(sc->dev, PCIR_SUBBUS_1, sc->subbus, 1); + device_printf(bus->dev, "grew bus range to %lu-%lu\n", + rman_get_start(bus->res), rman_get_end(bus->res)); + error = rman_manage_region(&bus->rman, old_end + 1, + rman_get_end(bus->res)); + if (error) + panic("Failed to add resource to rman"); + bus->sub = rman_get_end(bus->res); + pci_write_config(bus->dev, bus->sub_reg, bus->sub, 1); return (0); } -static struct resource * -pcib_alloc_subbus(struct pcib_softc *sc, device_t child, int *rid, u_long start, - u_long end, u_long count, u_int flags) +struct resource * +pcib_alloc_subbus(struct pcib_secbus *bus, device_t child, int *rid, + u_long start, u_long end, u_long count, u_int flags) { struct resource *res; - u_long start_free, end_free; + u_long start_free, end_free, new_end; /* * First, see if the request can be satisified by the existing * bus range. */ - res = pcib_suballoc_bus(sc, child, rid, start, end, count, flags); + res = pcib_suballoc_bus(bus, child, rid, start, end, count, flags); if (res != NULL) return (res); /* - * If this request is for a specific range, first attempt to - * grow the existing resource to accomodate this request. If - * that fails, retry the allocation using an arbitrary range. + * Figure out a range to grow the bus range. First, find the + * first bus number after the last allocated bus in the rman and + * enforce that as a minimum starting point for the range. */ - if (start + count - 1 == end) { - if (end < sc->subbus && pcib_grow_subbus(sc, end) == 0) { - res = pcib_suballoc_bus(sc, child, rid, start, end, - count, flags); - if (res != NULL) - return (res); - } - - res = pcib_suballoc_bus(sc, child, rid, 0ul, ~0ul, count, flags); - if (res != NULL) - return (res); - } + if (rman_last_free_region(&bus->rman, &start_free, &end_free) != 0 || + end_free != bus->sub) + start_free = bus->sub + 1; + if (start_free < start) + start_free = start; + new_end = start_free + count - 1; /* - * Finally, attempt to grow the existing resource to accomodate - * the request using an arbitrary range. + * See if this new range would satisfy the request if it + * succeeds. */ - if (rman_last_free_region(&sc->bus.rman, &start_free, &end_free) != 0 || - end_free != sc->subbus) - start_free = sc->subbus + 1; + if (new_end > end) + return (NULL); + + /* Finally, attempt to grow the existing resource. */ if (bootverbose || 1) { - device_printf(sc->dev, + device_printf(bus->dev, "attempting to grow bus range for %lu buses\n", count); printf("\tback candidate range: %lu-%lu\n", start_free, - start_free + count - 1); + new_end); } - if (pcib_grow_subbus(sc, start_free + count - 1) == 0) - return (pcib_suballoc_bus(sc, child, rid, 0ul, ~0ul, count, + if (pcib_grow_subbus(bus, new_end) == 0) + return (pcib_suballoc_bus(bus, child, rid, start, end, count, flags)); return (NULL); } @@ -876,8 +877,8 @@ sc->command = pci_read_config(dev, PCIR_COMMAND, 2); sc->pribus = pci_read_config(dev, PCIR_PRIBUS_1, 1); - sc->secbus = pci_read_config(dev, PCIR_SECBUS_1, 1); - sc->subbus = pci_read_config(dev, PCIR_SUBBUS_1, 1); + sc->bus.sec = pci_read_config(dev, PCIR_SECBUS_1, 1); + sc->bus.sub = pci_read_config(dev, PCIR_SUBBUS_1, 1); sc->bridgectl = pci_read_config(dev, PCIR_BRIDGECTL_1, 2); sc->seclat = pci_read_config(dev, PCIR_SECLAT_1, 1); #ifndef NEW_PCIB @@ -900,8 +901,8 @@ pci_write_config(dev, PCIR_COMMAND, sc->command, 2); pci_write_config(dev, PCIR_PRIBUS_1, sc->pribus, 1); - pci_write_config(dev, PCIR_SECBUS_1, sc->secbus, 1); - pci_write_config(dev, PCIR_SUBBUS_1, sc->subbus, 1); + pci_write_config(dev, PCIR_SECBUS_1, sc->bus.sec, 1); + pci_write_config(dev, PCIR_SUBBUS_1, sc->bus.sub, 1); pci_write_config(dev, PCIR_BRIDGECTL_1, sc->bridgectl, 2); pci_write_config(dev, PCIR_SECLAT_1, sc->seclat, 1); #ifdef NEW_PCIB @@ -956,9 +957,9 @@ SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "pribus", CTLFLAG_RD, &sc->pribus, 0, "Primary bus number"); SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "secbus", - CTLFLAG_RD, &sc->secbus, 0, "Secondary bus number"); + CTLFLAG_RD, &sc->bus.sec, 0, "Secondary bus number"); SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus", - CTLFLAG_RD, &sc->subbus, 0, "Subordinate bus number"); + CTLFLAG_RD, &sc->bus.sub, 0, "Subordinate bus number"); /* * Quirk handling. @@ -970,8 +971,8 @@ supbus = pci_read_config(dev, 0x41, 1); if (supbus != 0xff) { - sc->secbus = supbus + 1; - sc->subbus = supbus + 1; + sc->bus.sec = supbus + 1; + sc->bus.sub = supbus + 1; } break; } @@ -1007,9 +1008,9 @@ break; } freeenv(cp); - if (sc->subbus < 0xa) { + if (sc->bus.sub < 0xa) { pci_write_config(dev, PCIR_SUBBUS_1, 0xa, 1); - sc->subbus = pci_read_config(dev, PCIR_SUBBUS_1, 1); + sc->bus.sub = pci_read_config(dev, PCIR_SUBBUS_1, 1); } break; } @@ -1032,14 +1033,16 @@ #ifdef NEW_PCIB #ifdef PCI_RES_BUS - pcib_setup_secbus(sc); + sc->bus.sec_reg = PCIR_SECBUS_1; + sc->bus.sub_reg = PCIR_SUBBUS_1; + pcib_setup_secbus(dev, &sc->bus); #endif pcib_probe_windows(sc); #endif if (bootverbose) { device_printf(dev, " domain %d\n", sc->domain); - device_printf(dev, " secondary bus %d\n", sc->secbus); - device_printf(dev, " subordinate bus %d\n", sc->subbus); + device_printf(dev, " secondary bus %d\n", sc->bus.sec); + device_printf(dev, " subordinate bus %d\n", sc->bus.sub); #ifdef NEW_PCIB if (pcib_is_window_open(&sc->io)) device_printf(dev, " I/O decode 0x%jx-0x%jx\n", @@ -1095,8 +1098,8 @@ pcib_attach_common(dev); sc = device_get_softc(dev); - if (sc->secbus != 0) { - child = device_add_child(dev, "pci", sc->secbus); + if (sc->bus.sec != 0) { + child = device_add_child(dev, "pci", sc->bus.sec); if (child != NULL) return(bus_generic_attach(dev)); } @@ -1146,7 +1149,7 @@ *result = sc->domain; return(0); case PCIB_IVAR_BUS: - *result = sc->secbus; + *result = sc->bus.sec; return(0); } return(ENOENT); @@ -1155,14 +1158,12 @@ int pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) { - struct pcib_softc *sc = device_get_softc(dev); switch (which) { case PCIB_IVAR_DOMAIN: return(EINVAL); case PCIB_IVAR_BUS: - sc->secbus = value; - return(0); + return(EINVAL); } return(ENOENT); } @@ -1574,8 +1575,8 @@ switch (type) { #ifdef PCI_RES_BUS case PCI_RES_BUS: - return (pcib_alloc_subbus(sc, child, rid, start, end, count, - flags)); + return (pcib_alloc_subbus(&sc->bus, child, rid, start, end, + count, flags)); #endif case SYS_RES_IOPORT: if (pcib_is_isa_range(sc, start, end, count)) ==== //depot/projects/pci/sys/dev/pci/pcib_private.h#25 (text+ko) ==== @@ -81,15 +81,20 @@ int step; /* log_2 of window granularity */ const char *name; }; +#endif -#ifdef PCI_RES_BUS struct pcib_secbus { + u_int sec; + u_int sub; +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + device_t dev; struct rman rman; struct resource *res; const char *name; + int sec_reg; + int sub_reg; +#endif }; -#endif -#endif /* * Bridge-specific data. @@ -103,15 +108,11 @@ uint16_t command; /* command register */ u_int domain; /* domain number */ u_int pribus; /* primary bus number */ - u_int secbus; /* secondary bus number */ - u_int subbus; /* subordinate bus number */ + struct pcib_secbus bus; /* secondary bus numbers */ #ifdef NEW_PCIB struct pcib_window io; /* I/O port window */ struct pcib_window mem; /* memory window */ struct pcib_window pmem; /* prefetchable memory window */ -#ifdef PCI_RES_BUS - struct pcib_secbus bus; /* secondary bus numbers */ -#endif #else pci_addr_t pmembase; /* base address of prefetchable memory */ pci_addr_t pmemlimit; /* topmost address of prefetchable memory */ @@ -136,6 +137,10 @@ struct resource *r, u_long start, u_long end); int pci_domain_release_bus(int domain, device_t dev, int rid, struct resource *r); +struct resource *pcib_alloc_subbus(struct pcib_secbus *bus, device_t child, + int *rid, u_long start, u_long end, u_long count, + u_int flags); +void pcib_setup_secbus(device_t dev, struct pcib_secbus *bus); #endif int pcib_attach(device_t dev); void pcib_attach_common(device_t dev); ==== //depot/projects/pci/sys/sparc64/pci/apb.c#6 (text+ko) ==== @@ -177,9 +177,9 @@ pci_read_config(dev, PCIR_COMMAND, 2); sc->sc_bsc.ops_pcib_sc.pribus = pci_read_config(dev, PCIR_PRIBUS_1, 1); - sc->sc_bsc.ops_pcib_sc.secbus = + sc->sc_bsc.ops_pcib_sc.bus.sec = pci_read_config(dev, PCIR_SECBUS_1, 1); - sc->sc_bsc.ops_pcib_sc.subbus = + sc->sc_bsc.ops_pcib_sc.bus.sub = pci_read_config(dev, PCIR_SUBBUS_1, 1); sc->sc_bsc.ops_pcib_sc.bridgectl = pci_read_config(dev, PCIR_BRIDGECTL_1, 2); @@ -200,10 +200,10 @@ CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.pribus, 0, "Primary bus number"); SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "secbus", - CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.secbus, 0, + CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.bus.sec, 0, "Secondary bus number"); SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus", - CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.subbus, 0, + CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.bus.sub, 0, "Subordinate bus number"); ofw_pcib_gen_setup(dev); @@ -212,9 +212,9 @@ device_printf(dev, " domain %d\n", sc->sc_bsc.ops_pcib_sc.domain); device_printf(dev, " secondary bus %d\n", - sc->sc_bsc.ops_pcib_sc.secbus); + sc->sc_bsc.ops_pcib_sc.bus.sec); device_printf(dev, " subordinate bus %d\n", - sc->sc_bsc.ops_pcib_sc.subbus); + sc->sc_bsc.ops_pcib_sc.bus.sub); device_printf(dev, " I/O decode "); apb_map_print(sc->sc_iomap, APB_IO_SCALE); printf("\n"); From owner-p4-projects@FreeBSD.ORG Fri Jul 12 03:17:58 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5112A10F; Fri, 12 Jul 2013 03:17:58 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EF02C10D for ; Fri, 12 Jul 2013 03:17:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id E0699166C for ; Fri, 12 Jul 2013 03:17:57 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C3Hvx5036515 for ; Fri, 12 Jul 2013 03:17:57 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6C3Hv24036512 for perforce@freebsd.org; Fri, 12 Jul 2013 03:17:57 GMT (envelope-from jhb@freebsd.org) Date: Fri, 12 Jul 2013 03:17:57 GMT Message-Id: <201307120317.r6C3Hv24036512@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 231064 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 03:17:58 -0000 http://p4web.freebsd.org/@@231064?ac=10 Change 231064 by jhb@jhb_pippin on 2013/07/12 03:17:47 Move bus number allocation support code completely into the PCI front-end. Affected files ... .. //depot/projects/pci/sys/dev/pccbb/pccbb.c#7 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#7 edit Differences ... ==== //depot/projects/pci/sys/dev/pccbb/pccbb.c#7 (text+ko) ==== @@ -1503,11 +1503,6 @@ { struct cbb_softc *sc = device_get_softc(brdev); -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - if (type == PCI_RES_BUS) - return (pcib_alloc_subbus(&sc->bus, child, rid, start, end, - count, flags)); -#endif if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_alloc_resource(brdev, child, type, rid, start, end, count, flags)); @@ -1521,20 +1516,7 @@ struct resource *r) { struct cbb_softc *sc = device_get_softc(brdev); -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - int error; - if (type == PCI_RES_BUS) { - if (!rman_is_region_manager(r, &sc->bus.rman)) - return (EINVAL); - if (rman_get_flags(r) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, r); - if (error) - return (error); - } - return (rman_release_resource(r)); - } -#endif if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_release_resource(brdev, child, type, rid, r)); ==== //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#7 (text+ko) ==== @@ -797,6 +797,20 @@ } #if defined(NEW_PCIB) && defined(PCI_RES_BUS) +static struct resource * +cbb_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + struct cbb_softc *sc; + + sc = device_get_softc(bus); + if (type == PCI_RES_BUS) + return (pcib_alloc_subbus(&sc->bus, child, rid, start, end, + count, flags)); + return (cbb_alloc_resource(bus, child, type, rid, start, end, count, + flags)); +} + static int cbb_pci_adjust_resource(device_t bus, device_t child, int type, struct resource *r, u_long start, u_long end) @@ -811,6 +825,27 @@ } return (bus_generic_adjust_resource(bus, child, type, r, start, end)); } + +static int +cbb_pci_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + struct cbb_softc *sc; + int error; + + sc = device_get_softc(bus); + if (type == PCI_RES_BUS) { + if (!rman_is_region_manager(r, &sc->bus.rman)) + return (EINVAL); + if (rman_get_flags(r) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, r); + if (error) + return (error); + } + return (rman_release_resource(r)); + } + return (cbb_release_resource(bus, child, type, rid, r)); +} #endif /************************************************************************/ @@ -856,11 +891,14 @@ /* bus methods */ DEVMETHOD(bus_read_ivar, cbb_read_ivar), DEVMETHOD(bus_write_ivar, cbb_write_ivar), - DEVMETHOD(bus_alloc_resource, cbb_alloc_resource), #if defined(NEW_PCIB) && defined(PCI_RES_BUS) + DEVMETHOD(bus_alloc_resource, cbb_pci_alloc_resource), DEVMETHOD(bus_adjust_resource, cbb_pci_adjust_resource), + DEVMETHOD(bus_release_resource, cbb_pci_release_resource), +#else + DEVMETHOD(bus_alloc_resource, cbb_alloc_resource), + DEVMETHOD(bus_release_resource, cbb_release_resource), #endif - DEVMETHOD(bus_release_resource, cbb_release_resource), DEVMETHOD(bus_activate_resource, cbb_activate_resource), DEVMETHOD(bus_deactivate_resource, cbb_deactivate_resource), DEVMETHOD(bus_driver_added, cbb_driver_added), From owner-p4-projects@FreeBSD.ORG Fri Jul 12 14:03:42 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2D04B335; Fri, 12 Jul 2013 14:03:42 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AACA2332 for ; Fri, 12 Jul 2013 14:03:41 +0000 (UTC) (envelope-from jonathan@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 9BBF61864 for ; Fri, 12 Jul 2013 14:03:41 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CE3fmt026197 for ; Fri, 12 Jul 2013 14:03:41 GMT (envelope-from jonathan@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6CE3fcp026194 for perforce@freebsd.org; Fri, 12 Jul 2013 14:03:41 GMT (envelope-from jonathan@freebsd.org) Date: Fri, 12 Jul 2013 14:03:41 GMT Message-Id: <201307121403.r6CE3fcp026194@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jonathan@freebsd.org using -f From: Jonathan Anderson Subject: PERFORCE change 231080 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 14:03:42 -0000 http://p4web.freebsd.org/@@231080?ac=10 Change 231080 by jonathan@jonathan-on-joe on 2013/07/12 14:03:12 Pull in commit 21a7e6 to libtesla Affected files ... .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#14 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#14 (text+ko) ==== @@ -340,12 +340,21 @@ tesla_panic("TESLA: failure in '%s': bad transition", tcp->tc_name); } +static void +panic_errno(struct tesla_class *tcp, int errno, const char *message) +{ + + tesla_panic("TESLA: %s in '%s': %s", + tesla_strerror(errno), tcp->tc_name, message); +} + static const struct tesla_event_handlers failstop_handlers = { .teh_init = ev_noop, .teh_transition = ev_noop, .teh_clone = ev_noop, .teh_fail_no_instance = panic_no_instance, .teh_bad_transition = panic_bad_transition, + .teh_err = panic_errno, .teh_accept = ev_noop, .teh_ignored = ev_noop, }; From owner-p4-projects@FreeBSD.ORG Fri Jul 12 21:02:19 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 869198BC; Fri, 12 Jul 2013 21:02:19 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4677D8BA for ; Fri, 12 Jul 2013 21:02:19 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 1C6A01ED5 for ; Fri, 12 Jul 2013 21:02:19 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CL2Ial085407 for ; Fri, 12 Jul 2013 21:02:18 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6CL2IBl085404 for perforce@freebsd.org; Fri, 12 Jul 2013 21:02:18 GMT (envelope-from brooks@freebsd.org) Date: Fri, 12 Jul 2013 21:02:18 GMT Message-Id: <201307122102.r6CL2IBl085404@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 231100 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 21:02:19 -0000 http://p4web.freebsd.org/@@231100?ac=10 Change 231100 by brooks@brooks_zenith on 2013/07/12 21:01:31 Add a new option ALTERA_SDCARD_FAST_SIM which checks immediatly for success of I/O operations rather than queuing a task. Add ALTERA_SDCARD_FAST_SIM to the simulation config. Suggested by: rwatson Affected files ... .. //depot/projects/ctsrd/beribsd/src/sys/conf/options#10 edit .. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/sdcard/altera_sdcard.c#8 edit .. //depot/projects/ctsrd/beribsd/src/sys/mips/beri/std.beri#6 edit .. //depot/projects/ctsrd/beribsd/src/sys/mips/conf/BERI_SIM_BASE#2 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/sys/conf/options#10 (text+ko) ==== @@ -68,6 +68,7 @@ # Miscellaneous options. ADAPTIVE_LOCKMGRS ALQ +ALTERA_SDCARD_FAST_SIM opt_altera_sdcard.h AUDIT opt_global.h BOOTHOWTO opt_global.h BOOTVERBOSE opt_global.h ==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/sdcard/altera_sdcard.c#8 (text+ko) ==== @@ -31,6 +31,8 @@ #include __FBSDID("$FreeBSD: head/sys/dev/altera/sdcard/altera_sdcard.c 245380 2013-01-13 16:57:11Z rwatson $"); +#include "opt_altera_sdcard.h" + #include #include #include @@ -258,6 +260,9 @@ ALTERA_SDCARD_LOCK_ASSERT(sc); KASSERT(sc->as_currentbio != NULL, ("%s: no current I/O", __func__)); +#ifdef ALTERA_SDCARD_FAST_SIM +recheck: +#endif asr = altera_sdcard_read_asr(sc); /* @@ -299,9 +304,12 @@ /* * Finally, either start the next I/O or transition to the IDLE state. */ - if (bioq_first(&sc->as_bioq) != NULL) + if (bioq_first(&sc->as_bioq) != NULL) { altera_sdcard_nextio(sc); - else +#ifdef ALTERA_SDCARD_FAST_SIM + goto recheck; +#endif + } else sc->as_state = ALTERA_SDCARD_STATE_IDLE; } @@ -398,6 +406,8 @@ taskqueue_cancel_timeout(sc->as_taskqueue, &sc->as_task, NULL); altera_sdcard_nextio(sc); - taskqueue_enqueue_timeout(sc->as_taskqueue, &sc->as_task, - ALTERA_SDCARD_TIMEOUT_IO); +#ifdef ALTERA_SDCARD_FAST_SIM + altera_sdcard_task_io(sc); +#endif + altera_sdcard_task_rechedule(sc); } ==== //depot/projects/ctsrd/beribsd/src/sys/mips/beri/std.beri#6 (text+ko) ==== @@ -4,4 +4,4 @@ cpu CPU_MIPS4KC options BERI_LARGE_TLB - +options MIPS_DISABLE_L1_CACHE ==== //depot/projects/ctsrd/beribsd/src/sys/mips/conf/BERI_SIM_BASE#2 (text+ko) ==== @@ -12,6 +12,8 @@ options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=beri-sim.dts +options ALTERA_SDCARD_FAST_SIM + device altera_avgen device altera_jtag_uart device altera_sdcard From owner-p4-projects@FreeBSD.ORG Fri Jul 12 22:14:39 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CAE0DCD6; Fri, 12 Jul 2013 22:14:39 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8D14ECD3 for ; Fri, 12 Jul 2013 22:14:39 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 7E1111224 for ; Fri, 12 Jul 2013 22:14:39 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMEdi7096637 for ; Fri, 12 Jul 2013 22:14:39 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6CMEd0O096634 for perforce@freebsd.org; Fri, 12 Jul 2013 22:14:39 GMT (envelope-from jhb@freebsd.org) Date: Fri, 12 Jul 2013 22:14:39 GMT Message-Id: <201307122214.r6CMEd0O096634@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 231114 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 22:14:40 -0000 http://p4web.freebsd.org/@@231114?ac=10 Change 231114 by jhb@jhb_jhbbsd on 2013/07/12 22:13:46 Always write primary bus numbers for PCI bridges. Affected files ... .. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#8 edit .. //depot/projects/pci/sys/dev/pci/pci_pci.c#39 edit Differences ... ==== //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#8 (text+ko) ==== @@ -325,6 +325,7 @@ sc->bus.sub = pci_read_config(brdev, PCIR_SUBBUS_2, 1); sc->pribus = pcib_get_bus(parent); #if defined(NEW_PCIB) && defined(PCI_RES_BUS) + pci_write_config(brdev, PCIR_PRIBUS_2, sc->pribus, 1); sc->bus.sec_reg = PCIR_SECBUS_2; sc->bus.sub_reg = PCIR_SUBBUS_2; pcib_setup_secbus(brdev, &sc->bus); ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#39 (text+ko) ==== @@ -948,6 +948,13 @@ pcib_cfg_save(sc); /* + * The primary bus register should always be the bus of the + * parent. + */ + sc->pribus = pci_get_bus(dev); + pci_write_config(dev, PCIR_PRIBUS_1, sc->pribus, 1); + + /* * Setup sysctl reporting nodes */ sctx = device_get_sysctl_ctx(dev); From owner-p4-projects@FreeBSD.ORG Fri Jul 12 22:18:45 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4A5CE229; Fri, 12 Jul 2013 22:18:45 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0B4AE227 for ; Fri, 12 Jul 2013 22:18:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id F0B40124D for ; Fri, 12 Jul 2013 22:18:44 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMIiBl097102 for ; Fri, 12 Jul 2013 22:18:44 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6CMIilP097099 for perforce@freebsd.org; Fri, 12 Jul 2013 22:18:44 GMT (envelope-from jhb@freebsd.org) Date: Fri, 12 Jul 2013 22:18:44 GMT Message-Id: <201307122218.r6CMIilP097099@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 231119 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 22:18:45 -0000 http://p4web.freebsd.org/@@231119?ac=10 Change 231119 by jhb@jhb_jhbbsd on 2013/07/12 22:18:04 Trim debugging. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci_pci.c#40 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#40 (text+ko) ==== @@ -193,9 +193,8 @@ } /* - * This is used to reject allocations that conflict with an ISA alias - * before trying to grow the window. Note that this check overrides - * subtractive decode. + * This is used to reject I/O port allocations that conflict with an + * ISA alias range. */ static int pcib_is_isa_range(struct pcib_softc *sc, u_long start, u_long end, u_long count) @@ -230,8 +229,10 @@ return (0); alias: - device_printf(sc->dev, - "I/O range %#lx-%#lx overlaps with an ISA alias\n", start, end); + if (bootverbose) + device_printf(sc->dev, + "I/O range %#lx-%#lx overlaps with an ISA alias\n", start, + end); return (1); } @@ -320,10 +321,9 @@ w = &as->sc->io; rid = w->reg; - /* XXX */ - if (bootverbose || 1) + if (bootverbose) device_printf(as->sc->dev, - "Allocating non-ISA range %#lx-%#lx\n", start, end); + "allocating non-ISA range %#lx-%#lx\n", start, end); as->res[as->count] = bus_alloc_resource(as->sc->dev, SYS_RES_IOPORT, &rid, start, end, end - start + 1, 0); if (as->res[as->count] == NULL) @@ -338,10 +338,6 @@ struct alloc_state as; int i, new_count; - /* XXX */ - device_printf(sc->dev, "Allocating non-ISA ranges of %#lx-%#lx\n", - start, end); - /* First, see how many ranges we need. */ new_count = 0; pcib_walk_nonisa_ranges(start, end, count_ranges, &new_count);