From: patrick Date: Thu, 25 Feb 2021 23:07:48 +0000 (+0000) Subject: Add some infrastructure in the PCI chipset tag for pci_probe_device_hook() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=619b146d99f441b1442881c022ac42665e3f35f6;p=openbsd Add some infrastructure in the PCI chipset tag for pci_probe_device_hook() so that we can provide IOMMU-hooked bus DMA tags for each PCI device. ok kettenis@ --- diff --git a/sys/arch/arm/include/pci_machdep.h b/sys/arch/arm/include/pci_machdep.h index cb8e39f3490..b6d95c7eecf 100644 --- a/sys/arch/arm/include/pci_machdep.h +++ b/sys/arch/arm/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.16 2020/07/14 15:42:19 patrick Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.17 2021/02/25 23:07:48 patrick Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -47,6 +47,7 @@ struct arm32_pci_chipset { int (*pc_conf_size)(void *, pcitag_t); pcireg_t (*pc_conf_read)(void *, pcitag_t, int); void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t); + int (*pc_probe_device_hook)(void *, struct pci_attach_args *); void *pc_intr_v; int (*pc_intr_map)(struct pci_attach_args *, @@ -79,6 +80,8 @@ struct arm32_pci_chipset { (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r)) #define pci_conf_write(c, t, r, v) \ (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v)) +#define pci_probe_device_hook(c, a) \ + (*(c)->pc_probe_device_hook)((c)->pc_conf_v, (a)) #define pci_intr_map(c, ihp) \ (*(c)->pa_pc->pc_intr_map)((c), (ihp)) #define pci_intr_map_msi(c, ihp) \ @@ -95,7 +98,6 @@ struct arm32_pci_chipset { (nm)) #define pci_intr_disestablish(c, iv) \ (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv)) -#define pci_probe_device_hook(c, a) (0) #define pci_min_powerstate(c, t) (PCI_PMCSR_STATE_D3) #define pci_set_powerstate_md(c, t, s, p) diff --git a/sys/arch/arm64/dev/acpipci.c b/sys/arch/arm64/dev/acpipci.c index f10987392e2..c6944643c90 100644 --- a/sys/arch/arm64/dev/acpipci.c +++ b/sys/arch/arm64/dev/acpipci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpipci.c,v 1.24 2021/01/15 20:49:38 patrick Exp $ */ +/* $OpenBSD: acpipci.c,v 1.25 2021/02/25 23:07:48 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -106,6 +106,7 @@ void acpipci_decompose_tag(void *, pcitag_t, int *, int *, int *); int acpipci_conf_size(void *, pcitag_t); pcireg_t acpipci_conf_read(void *, pcitag_t, int); void acpipci_conf_write(void *, pcitag_t, int, pcireg_t); +int acpipci_probe_device_hook(void *, struct pci_attach_args *); int acpipci_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *acpipci_intr_string(void *, pci_intr_handle_t); @@ -181,6 +182,8 @@ acpipci_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc = pci_lookup_segment(seg); KASSERT(sc->sc_pc->pc_intr_v == NULL); + sc->sc_pc->pc_probe_device_hook = acpipci_probe_device_hook; + sc->sc_pc->pc_intr_v = sc; sc->sc_pc->pc_intr_map = acpipci_intr_map; sc->sc_pc->pc_intr_map_msi = _pci_intr_map_msi; @@ -340,6 +343,12 @@ acpipci_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) bus_space_write_4(am->am_iot, am->am_ioh, tag | reg, data); } +int +acpipci_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + int acpipci_intr_swizzle(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { diff --git a/sys/arch/arm64/dev/pciecam.c b/sys/arch/arm64/dev/pciecam.c index 0480a6c1595..4acd26611c9 100644 --- a/sys/arch/arm64/dev/pciecam.c +++ b/sys/arch/arm64/dev/pciecam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciecam.c,v 1.11 2020/11/19 17:42:19 kettenis Exp $ */ +/* $OpenBSD: pciecam.c,v 1.12 2021/02/25 23:07:48 patrick Exp $ */ /* * Copyright (c) 2013,2017 Patrick Wildt * @@ -100,6 +100,7 @@ void pciecam_decompose_tag(void *, pcitag_t, int *, int *, int *); int pciecam_conf_size(void *, pcitag_t); pcireg_t pciecam_conf_read(void *, pcitag_t, int); void pciecam_conf_write(void *, pcitag_t, int, pcireg_t); +int pciecam_probe_device_hook(void *, struct pci_attach_args *); int pciecam_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *pciecam_intr_string(void *, pci_intr_handle_t); void *pciecam_intr_establish(void *, pci_intr_handle_t, int, @@ -228,6 +229,7 @@ pciecam_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc.pc_conf_size = pciecam_conf_size; sc->sc_pc.pc_conf_read = pciecam_conf_read; sc->sc_pc.pc_conf_write = pciecam_conf_write; + sc->sc_pc.pc_probe_device_hook = pciecam_probe_device_hook; sc->sc_pc.pc_intr_v = sc; sc->sc_pc.pc_intr_map = pciecam_intr_map; @@ -319,6 +321,12 @@ pciecam_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) HWRITE4(sc, PCIE_ADDR_OFFSET(bus, dev, fn, reg & ~0x3), data); } +int +pciecam_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + int pciecam_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { diff --git a/sys/arch/arm64/include/pci_machdep.h b/sys/arch/arm64/include/pci_machdep.h index 06259db8e9d..4366fd97ca1 100644 --- a/sys/arch/arm64/include/pci_machdep.h +++ b/sys/arch/arm64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.7 2020/07/14 15:42:19 patrick Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.8 2021/02/25 23:07:48 patrick Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -59,6 +59,7 @@ struct arm64_pci_chipset { int (*pc_conf_size)(void *, pcitag_t); pcireg_t (*pc_conf_read)(void *, pcitag_t, int); void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t); + int (*pc_probe_device_hook)(void *, struct pci_attach_args *); void *pc_intr_v; int (*pc_intr_map)(struct pci_attach_args *, @@ -91,6 +92,8 @@ struct arm64_pci_chipset { (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r)) #define pci_conf_write(c, t, r, v) \ (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v)) +#define pci_probe_device_hook(c, a) \ + (*(c)->pc_probe_device_hook)((c)->pc_conf_v, (a)) #define pci_intr_map(c, ihp) \ (*(c)->pa_pc->pc_intr_map)((c), (ihp)) #define pci_intr_map_msi(c, ihp) \ @@ -107,7 +110,6 @@ struct arm64_pci_chipset { (nm)) #define pci_intr_disestablish(c, iv) \ (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv)) -#define pci_probe_device_hook(c, a) (0) #define pci_min_powerstate(c, t) (PCI_PMCSR_STATE_D3) #define pci_set_powerstate_md(c, t, s, p) diff --git a/sys/arch/armv7/marvell/mvpcie.c b/sys/arch/armv7/marvell/mvpcie.c index d0734973f76..1fc27d81e80 100644 --- a/sys/arch/armv7/marvell/mvpcie.c +++ b/sys/arch/armv7/marvell/mvpcie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mvpcie.c,v 1.2 2020/07/14 15:42:19 patrick Exp $ */ +/* $OpenBSD: mvpcie.c,v 1.3 2021/02/25 23:07:48 patrick Exp $ */ /* * Copyright (c) 2018 Patrick Wildt * Copyright (c) 2018 Mark Kettenis @@ -194,6 +194,7 @@ void mvpcie_decompose_tag(void *, pcitag_t, int *, int *, int *); int mvpcie_conf_size(void *, pcitag_t); pcireg_t mvpcie_conf_read(void *, pcitag_t, int); void mvpcie_conf_write(void *, pcitag_t, int, pcireg_t); +int mvpcie_probe_device_hook(void *, struct pci_attach_args *); int mvpcie_intr_map(struct pci_attach_args *, pci_intr_handle_t *); int mvpcie_intr_map_msi(struct pci_attach_args *, pci_intr_handle_t *); @@ -421,6 +422,7 @@ mvpcie_port_attach(struct mvpcie_softc *sc, struct mvpcie_port *po, int node) po->po_pc.pc_conf_size = mvpcie_conf_size; po->po_pc.pc_conf_read = mvpcie_conf_read; po->po_pc.pc_conf_write = mvpcie_conf_write; + po->po_pc.pc_probe_device_hook = mvpcie_probe_device_hook; po->po_pc.pc_intr_v = po; po->po_pc.pc_intr_map = mvpcie_intr_map; @@ -775,6 +777,12 @@ mvpcie_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) HWRITE4(po, PCIE_CONF_DATA, data); } +int +mvpcie_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + struct mvpcie_intr_handle { pci_chipset_tag_t ih_pc; pcitag_t ih_tag; diff --git a/sys/arch/armv7/vexpress/pciecam.c b/sys/arch/armv7/vexpress/pciecam.c index 8ab86f6f14c..92bdcbcde03 100644 --- a/sys/arch/armv7/vexpress/pciecam.c +++ b/sys/arch/armv7/vexpress/pciecam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciecam.c,v 1.2 2020/07/14 15:42:19 patrick Exp $ */ +/* $OpenBSD: pciecam.c,v 1.3 2021/02/25 23:07:48 patrick Exp $ */ /* * Copyright (c) 2013,2017 Patrick Wildt * @@ -98,6 +98,7 @@ void pciecam_decompose_tag(void *, pcitag_t, int *, int *, int *); int pciecam_conf_size(void *, pcitag_t); pcireg_t pciecam_conf_read(void *, pcitag_t, int); void pciecam_conf_write(void *, pcitag_t, int, pcireg_t); +int pciecam_probe_device_hook(void *, struct pci_attach_args *); int pciecam_intr_map(struct pci_attach_args *, pci_intr_handle_t *); int pciecam_intr_map_msi(struct pci_attach_args *, pci_intr_handle_t *); int pciecam_intr_map_msix(struct pci_attach_args *, int, pci_intr_handle_t *); @@ -222,6 +223,7 @@ pciecam_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc.pc_conf_size = pciecam_conf_size; sc->sc_pc.pc_conf_read = pciecam_conf_read; sc->sc_pc.pc_conf_write = pciecam_conf_write; + sc->sc_pc.pc_probe_device_hook = pciecam_probe_device_hook; sc->sc_pc.pc_intr_v = sc; sc->sc_pc.pc_intr_map = pciecam_intr_map; @@ -306,6 +308,12 @@ pciecam_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) HWRITE4(sc, PCIE_ADDR_OFFSET(bus, dev, fn, reg & ~0x3), data); } +int +pciecam_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + struct pciecam_intr_handle { pci_chipset_tag_t ih_pc; pcitag_t ih_tag; diff --git a/sys/dev/fdt/bcm2711_pcie.c b/sys/dev/fdt/bcm2711_pcie.c index 0533e0df01a..0e404d72429 100644 --- a/sys/dev/fdt/bcm2711_pcie.c +++ b/sys/dev/fdt/bcm2711_pcie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcm2711_pcie.c,v 1.4 2021/01/20 12:44:45 kettenis Exp $ */ +/* $OpenBSD: bcm2711_pcie.c,v 1.5 2021/02/25 23:07:49 patrick Exp $ */ /* * Copyright (c) 2020 Mark Kettenis * @@ -100,6 +100,7 @@ void bcmpcie_decompose_tag(void *, pcitag_t, int *, int *, int *); int bcmpcie_conf_size(void *, pcitag_t); pcireg_t bcmpcie_conf_read(void *, pcitag_t, int); void bcmpcie_conf_write(void *, pcitag_t, int, pcireg_t); +int bcmpcie_probe_device_hook(void *, struct pci_attach_args *); int bcmpcie_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *bcmpcie_intr_string(void *, pci_intr_handle_t); @@ -223,6 +224,7 @@ bcmpcie_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc.pc_conf_size = bcmpcie_conf_size; sc->sc_pc.pc_conf_read = bcmpcie_conf_read; sc->sc_pc.pc_conf_write = bcmpcie_conf_write; + sc->sc_pc.pc_probe_device_hook = bcmpcie_probe_device_hook; sc->sc_pc.pc_intr_v = sc; sc->sc_pc.pc_intr_map = bcmpcie_intr_map; @@ -317,6 +319,12 @@ bcmpcie_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) HWRITE4(sc, PCIE_EXT_CFG_DATA + reg, data); } +int +bcmpcie_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + int bcmpcie_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { diff --git a/sys/dev/fdt/dwpcie.c b/sys/dev/fdt/dwpcie.c index 07443c41211..70637fc9b4c 100644 --- a/sys/dev/fdt/dwpcie.c +++ b/sys/dev/fdt/dwpcie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwpcie.c,v 1.24 2020/12/28 12:24:31 kettenis Exp $ */ +/* $OpenBSD: dwpcie.c,v 1.25 2021/02/25 23:07:49 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -264,6 +264,7 @@ void dwpcie_decompose_tag(void *, pcitag_t, int *, int *, int *); int dwpcie_conf_size(void *, pcitag_t); pcireg_t dwpcie_conf_read(void *, pcitag_t, int); void dwpcie_conf_write(void *, pcitag_t, int, pcireg_t); +int dwpcie_probe_device_hook(void *, struct pci_attach_args *); int dwpcie_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *dwpcie_intr_string(void *, pci_intr_handle_t); @@ -535,6 +536,7 @@ dwpcie_attach_deferred(struct device *self) sc->sc_pc.pc_conf_size = dwpcie_conf_size; sc->sc_pc.pc_conf_read = dwpcie_conf_read; sc->sc_pc.pc_conf_write = dwpcie_conf_write; + sc->sc_pc.pc_probe_device_hook = dwpcie_probe_device_hook; sc->sc_pc.pc_intr_v = sc; sc->sc_pc.pc_intr_map = dwpcie_intr_map; @@ -1130,6 +1132,12 @@ dwpcie_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) sc->sc_io_bus_addr, sc->sc_io_size); } +int +dwpcie_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + int dwpcie_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { diff --git a/sys/dev/fdt/mvkpcie.c b/sys/dev/fdt/mvkpcie.c index b037d7dd9d3..ca1ea1a8a4a 100644 --- a/sys/dev/fdt/mvkpcie.c +++ b/sys/dev/fdt/mvkpcie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mvkpcie.c,v 1.8 2021/01/19 19:46:40 kettenis Exp $ */ +/* $OpenBSD: mvkpcie.c,v 1.9 2021/02/25 23:07:49 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * Copyright (c) 2020 Patrick Wildt @@ -231,6 +231,7 @@ void mvkpcie_decompose_tag(void *, pcitag_t, int *, int *, int *); int mvkpcie_conf_size(void *, pcitag_t); pcireg_t mvkpcie_conf_read(void *, pcitag_t, int); void mvkpcie_conf_write(void *, pcitag_t, int, pcireg_t); +int mvkpcie_probe_device_hook(void *, struct pci_attach_args *); int mvkpcie_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *mvkpcie_intr_string(void *, pci_intr_handle_t); @@ -516,6 +517,7 @@ mvkpcie_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc.pc_conf_size = mvkpcie_conf_size; sc->sc_pc.pc_conf_read = mvkpcie_conf_read; sc->sc_pc.pc_conf_write = mvkpcie_conf_write; + sc->sc_pc.pc_probe_device_hook = mvkpcie_probe_device_hook; sc->sc_pc.pc_intr_v = sc; sc->sc_pc.pc_intr_map = mvkpcie_intr_map; @@ -727,6 +729,12 @@ mvkpcie_conf_write(void *v, pcitag_t tag, int off, pcireg_t data) } } +int +mvkpcie_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + int mvkpcie_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { diff --git a/sys/dev/fdt/rkpcie.c b/sys/dev/fdt/rkpcie.c index 49765815fdf..dbcd530009f 100644 --- a/sys/dev/fdt/rkpcie.c +++ b/sys/dev/fdt/rkpcie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkpcie.c,v 1.11 2020/07/14 15:42:19 patrick Exp $ */ +/* $OpenBSD: rkpcie.c,v 1.12 2021/02/25 23:07:49 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -140,6 +140,7 @@ void rkpcie_decompose_tag(void *, pcitag_t, int *, int *, int *); int rkpcie_conf_size(void *, pcitag_t); pcireg_t rkpcie_conf_read(void *, pcitag_t, int); void rkpcie_conf_write(void *, pcitag_t, int, pcireg_t); +int rkpcie_probe_device_hook(void *, struct pci_attach_args *); int rkpcie_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *rkpcie_intr_string(void *, pci_intr_handle_t); @@ -357,6 +358,7 @@ rkpcie_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc.pc_conf_size = rkpcie_conf_size; sc->sc_pc.pc_conf_read = rkpcie_conf_read; sc->sc_pc.pc_conf_write = rkpcie_conf_write; + sc->sc_pc.pc_probe_device_hook = rkpcie_probe_device_hook; sc->sc_pc.pc_intr_v = sc; sc->sc_pc.pc_intr_map = rkpcie_intr_map; @@ -546,6 +548,12 @@ rkpcie_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) } } +int +rkpcie_probe_device_hook(void *v, struct pci_attach_args *pa) +{ + return 0; +} + int rkpcie_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) {