Date: Mon, 24 Apr 2023 13:54:16 +0200 From: tuexen@fh-muenster.de To: Andrew Turner <andrew@FreeBSD.org> Cc: "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org> Subject: Re: git: 7029f2c887a1 - main - Allow pci_host_generic attachments to manage registers Message-ID: <54618885-6BE8-4210-BAD4-B5E942A83F9B@fh-muenster.de> In-Reply-To: <202304241134.33OBYBwu071123@gitrepo.freebsd.org> References: <202304241134.33OBYBwu071123@gitrepo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] > On 24. Apr 2023, at 13:34, Andrew Turner <andrew@FreeBSD.org> wrote: > > The branch main has been updated by andrew: > > URL: https://cgit.FreeBSD.org/src/commit/?id=7029f2c887a16c823faf08e8a79dc0d3887989ab > > commit 7029f2c887a16c823faf08e8a79dc0d3887989ab > Author: Andrew Turner <andrew@FreeBSD.org> > AuthorDate: 2022-06-04 10:59:46 +0000 > Commit: Andrew Turner <andrew@FreeBSD.org> > CommitDate: 2023-04-24 11:33:50 +0000 > > Allow pci_host_generic attachments to manage registers > > To allow for attachments that don't use memory mapped registers add > a flag they can set when the base driver shouldn't map them. > > Sponsored by: Arm Ltd > Differential Revision: https://reviews.freebsd.org/D39227 Not sure if it is related to this commit. But trying to run a kernel with this revision on VM Fusion on an M1 MacBook Pro results in: Mounting from ufs:/dev/nda0p2 failed with error 19. A kernel build with https://cgit.FreeBSD.org/src/commit/?id=390c31c4289e66f1bd9cb2349d6e55fd4dc468f8 <https://cgit.freebsd.org/src/commit/?id=390c31c4289e66f1bd9cb2349d6e55fd4dc468f8> boots without problems. Best regards Michael > --- > sys/dev/pci/pci_host_generic.c | 45 +++++++++++++++++++++++------------------- > sys/dev/pci/pci_host_generic.h | 2 ++ > 2 files changed, 27 insertions(+), 20 deletions(-) > > diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c > index 986318548eab..ca74b0c650c3 100644 > --- a/sys/dev/pci/pci_host_generic.c > +++ b/sys/dev/pci/pci_host_generic.c > @@ -106,27 +106,30 @@ pci_host_generic_core_attach(device_t dev) > if (error != 0) > return (error); > > - rid = 0; > - sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, > - PCI_RF_FLAGS | RF_ACTIVE); > - if (sc->res == NULL) { > - device_printf(dev, "could not allocate memory.\n"); > - error = ENXIO; > - goto err_resource; > - } > + if ((sc->quirks & PCIE_CUSTOM_CONFIG_SPACE_QUIRK) == 0) { > + rid = 0; > + sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, > + PCI_RF_FLAGS | RF_ACTIVE); > + if (sc->res == NULL) { > + device_printf(dev, "could not allocate memory.\n"); > + error = ENXIO; > + goto err_resource; > + } > #ifdef PCI_UNMAPPED > - resource_init_map_request(&req); > - req.memattr = VM_MEMATTR_DEVICE_NP; > - error = bus_map_resource(dev, SYS_RES_MEMORY, sc->res, &req, &map); > - if (error != 0) { > - device_printf(dev, "could not map memory.\n"); > - return (error); > - } > - rman_set_mapping(sc->res, &map); > + resource_init_map_request(&req); > + req.memattr = VM_MEMATTR_DEVICE_NP; > + error = bus_map_resource(dev, SYS_RES_MEMORY, sc->res, &req, > + &map); > + if (error != 0) { > + device_printf(dev, "could not map memory.\n"); > + return (error); > + } > + rman_set_mapping(sc->res, &map); > #endif > > - sc->bst = rman_get_bustag(sc->res); > - sc->bsh = rman_get_bushandle(sc->res); > + sc->bst = rman_get_bustag(sc->res); > + sc->bsh = rman_get_bushandle(sc->res); > + } > > sc->has_pmem = false; > sc->pmem_rman.rm_type = RMAN_ARRAY; > @@ -196,7 +199,8 @@ err_io_rman: > err_mem_rman: > rman_fini(&sc->pmem_rman); > err_pmem_rman: > - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res); > + if (sc->res != NULL) > + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res); > err_resource: > bus_dma_tag_destroy(sc->dmat); > return (error); > @@ -217,7 +221,8 @@ pci_host_generic_core_detach(device_t dev) > rman_fini(&sc->io_rman); > rman_fini(&sc->mem_rman); > rman_fini(&sc->pmem_rman); > - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res); > + if (sc->res != NULL) > + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res); > bus_dma_tag_destroy(sc->dmat); > > return (0); > diff --git a/sys/dev/pci/pci_host_generic.h b/sys/dev/pci/pci_host_generic.h > index 80da4f523165..b3242c8bdaf5 100644 > --- a/sys/dev/pci/pci_host_generic.h > +++ b/sys/dev/pci/pci_host_generic.h > @@ -90,6 +90,8 @@ struct generic_pcie_core_softc { > > /* Quirks */ > #define PCIE_ECAM_DESIGNWARE_QUIRK (1 << 0) > +/* Child will map resources to access config registers */ > +#define PCIE_CUSTOM_CONFIG_SPACE_QUIRK (1 << 1) > > DECLARE_CLASS(generic_pcie_core_driver); > [-- Attachment #2 --] 0 *H 010 `He 0 *H 00 %ف0 *H 010 UDE1+0)U "T-Systems Enterprise Services GmbH10UT-Systems Trust Center1%0#UT-TeleSec GlobalRoot Class 20 160222133822Z 310222235959Z010 UDE1E0CU <Verein zur Foerderung eines Deutschen Forschungsnetzes e. V.10UDFN-PKI1-0+U$DFN-Verein Certification Authority 20"0 *H 0 `fAsMg9Z`GNWKVlUvFEc>pԫT#7( ]Ę7 fxJ2)y T_Jx4twMYZ/l<
