diff options
author | royger <royger@FreeBSD.org> | 2015-10-21 10:44:07 +0000 |
---|---|---|
committer | royger <royger@FreeBSD.org> | 2015-10-21 10:44:07 +0000 |
commit | ee786e40e8b0e419c466fa43971ad81e124ba78e (patch) | |
tree | cda0a8ef7b24d6ba166ed512398b1479cebfceb5 /sys/x86/xen | |
parent | d31f5fb7b9df13b2e972e2c0eeea7100551cd8f2 (diff) | |
download | FreeBSD-src-ee786e40e8b0e419c466fa43971ad81e124ba78e.zip FreeBSD-src-ee786e40e8b0e419c466fa43971ad81e124ba78e.tar.gz |
xen: Code cleanup and small bug fixes
xen/hypervisor.h:
- Remove unused helpers: MULTI_update_va_mapping, is_initial_xendomain,
is_running_on_xen
- Remove unused define CONFIG_X86_PAE
- Remove unused variable xen_start_info: note that it's used inpcifront
which is not built at all
- Remove forward declaration of HYPERVISOR_crash
xen/xen-os.h:
- Remove unused define CONFIG_X86_PAE
- Drop unused helpers: test_and_clear_bit, clear_bit,
force_evtchn_callback
- Implement a generic version (based on ofed/include/linux/bitops.h) of
set_bit and test_bit and prefix them by xen_ to avoid any use by other
code than Xen. Note that It would be worth to investigate a generic
implementation in FreeBSD.
- Replace barrier() by __compiler_membar()
- Replace cpu_relax() by cpu_spinwait(): it's exactly the same as rep;nop
= pause
xen/xen_intr.h:
- Move the prototype of xen_intr_handle_upcall in it: Use by all the
platform
x86/xen/xen_intr.c:
- Use BITSET* for the enabledbits: Avoid to use custom helpers
- test_bit/set_bit has been renamed to xen_test_bit/xen_set_bit
- Don't export the variable xen_intr_pcpu
dev/xen/blkback/blkback.c:
- Fix the string format when XBB_DEBUG is enabled: host_addr is typed
uint64_t
dev/xen/balloon/balloon.c:
- Remove set but not used variable
- Use the correct type for frame_list: xen_pfn_t represents the frame
number on any architecture
dev/xen/control/control.c:
- Return BUS_PROBE_WILDCARD in xs_probe: Returning 0 in a probe callback
means the driver can handle this device. If by any chance xenstore is the
first driver, every new device with the driver is unset will use
xenstore.
dev/xen/grant-table/grant_table.c:
- Remove unused cmpxchg
- Drop unused include opt_pmap.h: Doesn't exist on ARM64 and it doesn't
contain anything required for the code on x86
dev/xen/netfront/netfront.c:
- Use the correct type for rx_pfn_array: xen_pfn_t represents the frame
number on any architecture
dev/xen/netback/netback.c:
- Use the correct type for gmfn: xen_pfn_t represents the frame number on
any architecture
dev/xen/xenstore/xenstore.c:
- Return BUS_PROBE_WILDCARD in xctrl_probe: Returning 0 in a probe callback
means the driver can handle this device. If by any chance xenstore is the
first driver, every new device with the driver is unset will use xenstore.
Note that with the changes, x86/include/xen/xen-os.h doesn't contain anymore
arch-specific code. Although, a new series will add some helpers that differ
between x86 and ARM64, so I've kept the headers for now.
Submitted by: Julien Grall <julien.grall@citrix.com>
Reviewed by: royger
Differential Revision: https://reviews.freebsd.org/D3921
Sponsored by: Citrix Systems R&D
Diffstat (limited to 'sys/x86/xen')
-rw-r--r-- | sys/x86/xen/xen_intr.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index a728ddb..b49376b 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -71,6 +71,9 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_XENINTR, "xen_intr", "Xen Interrupt Services"); +#define ENABLED_SETSIZE (sizeof(u_long) * 8) +BITSET_DEFINE(enabledbits, ENABLED_SETSIZE) + /** * Per-cpu event channel processing state. */ @@ -95,14 +98,14 @@ struct xen_intr_pcpu_data { * A bitmap of ports that can be serviced from this CPU. * A set bit means interrupt handling is enabled. */ - u_long evtchn_enabled[sizeof(u_long) * 8]; + struct enabledbits evtchn_enabled; }; /* * Start the scan at port 0 by initializing the last scanned * location as the highest numbered event channel port. */ -DPCPU_DEFINE(struct xen_intr_pcpu_data, xen_intr_pcpu) = { +static DPCPU_DEFINE(struct xen_intr_pcpu_data, xen_intr_pcpu) = { .last_processed_l1i = LONG_BIT - 1, .last_processed_l2i = LONG_BIT - 1 }; @@ -212,7 +215,7 @@ evtchn_cpu_mask_port(u_int cpu, evtchn_port_t port) struct xen_intr_pcpu_data *pcpu; pcpu = DPCPU_ID_PTR(cpu, xen_intr_pcpu); - clear_bit(port, pcpu->evtchn_enabled); + BIT_CLR_ATOMIC(ENABLED_SETSIZE, port, &pcpu->evtchn_enabled); } /** @@ -234,7 +237,7 @@ evtchn_cpu_unmask_port(u_int cpu, evtchn_port_t port) struct xen_intr_pcpu_data *pcpu; pcpu = DPCPU_ID_PTR(cpu, xen_intr_pcpu); - set_bit(port, pcpu->evtchn_enabled); + BIT_SET_ATOMIC(ENABLED_SETSIZE, port, &pcpu->evtchn_enabled); } /** @@ -498,7 +501,7 @@ xen_intr_active_ports(struct xen_intr_pcpu_data *pcpu, shared_info_t *sh, { return (sh->evtchn_pending[idx] & ~sh->evtchn_mask[idx] - & pcpu->evtchn_enabled[idx]); + & pcpu->evtchn_enabled.__bits[idx]); } /** @@ -634,8 +637,10 @@ xen_intr_init(void *dummy __unused) */ CPU_FOREACH(i) { pcpu = DPCPU_ID_PTR(i, xen_intr_pcpu); - memset(pcpu->evtchn_enabled, i == 0 ? ~0 : 0, - sizeof(pcpu->evtchn_enabled)); + if (i == 0) + BIT_FILL(ENABLED_SETSIZE, &pcpu->evtchn_enabled); + else + BIT_ZERO(ENABLED_SETSIZE, &pcpu->evtchn_enabled); xen_intr_intrcnt_add(i); } @@ -748,8 +753,11 @@ xen_intr_resume(struct pic *unused, bool suspend_cancelled) struct xen_intr_pcpu_data *pcpu; pcpu = DPCPU_ID_PTR(i, xen_intr_pcpu); - memset(pcpu->evtchn_enabled, - i == 0 ? ~0 : 0, sizeof(pcpu->evtchn_enabled)); + + if (i == 0) + BIT_FILL(ENABLED_SETSIZE, &pcpu->evtchn_enabled); + else + BIT_ZERO(ENABLED_SETSIZE, &pcpu->evtchn_enabled); } /* Mask all event channels. */ @@ -1033,7 +1041,7 @@ xen_intr_pirq_eoi_source(struct intsrc *base_isrc) isrc = (struct xenisrc *)base_isrc; - if (test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)) { + if (xen_test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)) { struct physdev_eoi eoi = { .irq = isrc->xi_pirq }; error = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); @@ -1070,7 +1078,7 @@ xen_intr_pirq_enable_intr(struct intsrc *base_isrc) * Since the dynamic PIRQ EOI map is not available * mark the PIRQ as needing EOI unconditionally. */ - set_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map); + xen_set_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map); } } @@ -1591,20 +1599,21 @@ xen_intr_dump_port(struct xenisrc *isrc) db_printf("\tPirq: %d ActiveHi: %d EdgeTrigger: %d " "NeedsEOI: %d\n", isrc->xi_pirq, isrc->xi_activehi, isrc->xi_edgetrigger, - !!test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)); + !!xen_test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)); } if (isrc->xi_type == EVTCHN_TYPE_VIRQ) db_printf("\tVirq: %d\n", isrc->xi_virq); db_printf("\tMasked: %d Pending: %d\n", - !!test_bit(isrc->xi_port, &s->evtchn_mask[0]), - !!test_bit(isrc->xi_port, &s->evtchn_pending[0])); + !!xen_test_bit(isrc->xi_port, &s->evtchn_mask[0]), + !!xen_test_bit(isrc->xi_port, &s->evtchn_pending[0])); db_printf("\tPer-CPU Masks: "); CPU_FOREACH(i) { pcpu = DPCPU_ID_PTR(i, xen_intr_pcpu); db_printf("cpu#%d: %d ", i, - !!test_bit(isrc->xi_port, pcpu->evtchn_enabled)); + BIT_ISSET(ENABLED_SETSIZE, isrc->xi_port, + &pcpu->evtchn_enabled)); } db_printf("\n"); } |