diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-07-25 22:45:54 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-07-25 22:45:54 +0000 |
commit | 39da28c26f8e37982df545dd6fdd23f14bc4db23 (patch) | |
tree | 3340a542f8895936e42f370cf99189c7c2892fe4 | |
parent | f7d968df7030d7682718db79bc953cddd46192f6 (diff) |
Enable sharing of root complex when appropriate.
-rw-r--r-- | sys/arch/sparc64/dev/vpci.c | 21 | ||||
-rw-r--r-- | sys/arch/sparc64/include/hypervisor.h | 3 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/autoconf.c | 22 |
3 files changed, 40 insertions, 6 deletions
diff --git a/sys/arch/sparc64/dev/vpci.c b/sys/arch/sparc64/dev/vpci.c index 3ab0f8e1e15..6d3c88ef18c 100644 --- a/sys/arch/sparc64/dev/vpci.c +++ b/sys/arch/sparc64/dev/vpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vpci.c,v 1.27 2019/07/25 21:11:24 kettenis Exp $ */ +/* $OpenBSD: vpci.c,v 1.28 2019/07/25 22:45:53 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org> * @@ -90,6 +90,8 @@ struct vpci_softc { int sc_node; }; +uint64_t sun4v_group_sdio_major; + int vpci_match(struct device *, void *, void *); void vpci_attach(struct device *, struct device *, void *); void vpci_init_iommu(struct vpci_softc *, struct vpci_pbm *); @@ -152,6 +154,7 @@ vpci_attach(struct device *parent, struct device *self, void *aux) struct pcibus_attach_args pba; struct vpci_pbm *pbm; int *busranges = NULL, nranges; + int virtual; sc->sc_dmat = ma->ma_dmatag; sc->sc_bust = ma->ma_bustag; @@ -201,6 +204,22 @@ vpci_attach(struct device *parent, struct device *self, void *aux) free(busranges, M_DEVBUF, 0); config_found(&sc->sc_dv, &pba, vpci_print); + + /* + * Signal that we're ready to share this root complex with our + * guests. + */ + virtual = (OF_getproplen(ma->ma_node, "virtual-root-complex") == 0); + if (sun4v_group_sdio_major > 0 && !virtual) { + int err; + + err = hv_pci_iov_root_configured(pbm->vp_devhandle); + if (err != H_EOK) { + printf("%s: pci_iov_root_configured: err %x\n", + sc->sc_dv.dv_xname, err); + } + + } } void diff --git a/sys/arch/sparc64/include/hypervisor.h b/sys/arch/sparc64/include/hypervisor.h index afa2f0f1825..1bd3c71bb02 100644 --- a/sys/arch/sparc64/include/hypervisor.h +++ b/sys/arch/sparc64/include/hypervisor.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hypervisor.h,v 1.18 2019/07/25 18:30:40 kettenis Exp $ */ +/* $OpenBSD: hypervisor.h,v 1.19 2019/07/25 22:45:53 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -339,6 +339,7 @@ int64_t hv_rng_data_read(paddr_t raddr, uint64_t *delta); #define H_ECHANNEL 16 extern uint64_t sun4v_group_interrupt_major; +extern uint64_t sun4v_group_sdio_major; int64_t sun4v_intr_devino_to_sysino(uint64_t, uint64_t, uint64_t *); int64_t sun4v_intr_setcookie(uint64_t, uint64_t, uint64_t); diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c index b4cc09afd45..1e059dcad67 100644 --- a/sys/arch/sparc64/sparc64/autoconf.c +++ b/sys/arch/sparc64/sparc64/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.131 2018/01/27 22:55:23 naddy Exp $ */ +/* $OpenBSD: autoconf.c,v 1.132 2019/07/25 22:45:53 kettenis Exp $ */ /* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */ /* @@ -172,6 +172,7 @@ char sun4v_soft_state_booting[] __align32 = "OpenBSD booting"; char sun4v_soft_state_running[] __align32 = "OpenBSD running"; void sun4v_interrupt_init(void); +void sun4v_sdio_init(void); #endif #ifdef DEBUG @@ -439,6 +440,7 @@ bootstrap(int nctx) sun4v_soft_state_init(); sun4v_set_soft_state(SIS_TRANSITION, sun4v_soft_state_booting); sun4v_interrupt_init(); + sun4v_sdio_init(); } #endif } @@ -736,8 +738,9 @@ cpu_configure(void) #ifdef SUN4V -#define HSVC_GROUP_INTERRUPT 0x002 -#define HSVC_GROUP_SOFT_STATE 0x003 +#define HSVC_GROUP_INTERRUPT 0x002 +#define HSVC_GROUP_SOFT_STATE 0x003 +#define HSVC_GROUP_SDIO 0x108 int sun4v_soft_state_initialized = 0; @@ -777,10 +780,21 @@ sun4v_interrupt_init(void) if (prom_set_sun4v_api_version(HSVC_GROUP_INTERRUPT, 3, 0, &minor)) return; - + sun4v_group_interrupt_major = 3; } +void +sun4v_sdio_init(void) +{ + uint64_t minor; + + if (prom_set_sun4v_api_version(HSVC_GROUP_SDIO, 1, 0, &minor)) + return; + + sun4v_group_sdio_major = 1; +} + #endif void |