Date: Tue, 21 Jul 2015 10:24:48 -0600 From: Warner Losh <imp@bsdimp.com> To: Zbigniew Bodek <zbb@semihalf.com> Cc: Andrew Turner <andrew@fubar.geek.nz>, Zbigniew Bodek <zbb@freebsd.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r285752 - in head/sys: arm64/arm64 dev/pci Message-ID: <90C4DA24-6770-4DB5-AF87-20CB8E812657@bsdimp.com> In-Reply-To: <CAG7dG%2BygcdFussR6aAFF1ojL6MBafCY89KTrDe9r-CDAvJ0NeQ@mail.gmail.com> References: <201507211447.t6LElO3r098030@repo.freebsd.org> <20150721160145.65c9798b@bender> <CAG7dG%2BygcdFussR6aAFF1ojL6MBafCY89KTrDe9r-CDAvJ0NeQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_BC466D0C-78A5-4437-812A-B519F59F46FE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Zbigniew, This is a great brief explanation. Perhaps a one or two line comment to this effect would be useful for others trying to figure it out later? Warner > On Jul 21, 2015, at 10:02 AM, Zbigniew Bodek <zbb@semihalf.com> wrote: >=20 > Hello Andrew, >=20 > Please check in-line. >=20 > Best regards > zbb >=20 > 2015-07-21 17:01 GMT+02:00 Andrew Turner <andrew@fubar.geek.nz>: >> On Tue, 21 Jul 2015 14:47:24 +0000 (UTC) >> Zbigniew Bodek <zbb@FreeBSD.org> wrote: >>=20 >>> Author: zbb >>> Date: Tue Jul 21 14:47:23 2015 >>> New Revision: 285752 >>> URL: https://svnweb.freebsd.org/changeset/base/285752 >>>=20 >>> Log: >>> Add support for vendor specific function for PCI devid acquisition >>> in ITS >>> It is possible that some HW will use different PCI devids, >>> hence allow to replace the default domain:bus:slot:func schema >>> by implementing and registering custom function. >>>=20 >>> Obtained from: Semihalf >>> Sponsored by: The FreeBSD Foundation >>> Differential Revision: https://reviews.freebsd.org/D3118 >>>=20 >>> Modified: >>> head/sys/arm64/arm64/gic_v3_its.c >>> head/sys/arm64/arm64/gic_v3_var.h >>> head/sys/dev/pci/pcireg.h >>>=20 >>> Modified: head/sys/arm64/arm64/gic_v3_its.c >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- head/sys/arm64/arm64/gic_v3_its.c Tue Jul 21 14:39:34 >>> 2015 (r285751) +++ head/sys/arm64/arm64/gic_v3_its.c >>> Tue Jul 21 14:47:23 2015 (r285752) @@ -44,6 +44,7 @@ >>> __FBSDID("$FreeBSD$"); #include <sys/lock.h> >>> #include <sys/mutex.h> >>>=20 >>> +#include <dev/pci/pcireg.h> >>> #include <dev/pci/pcivar.h> >>>=20 >>> #include <vm/vm.h> >>> @@ -89,6 +90,7 @@ static void its_free_tables(struct gic_v >>> static void its_init_commandq(struct gic_v3_its_softc *); >>> static int its_init_cpu(struct gic_v3_its_softc *); >>> static void its_init_cpu_collection(struct gic_v3_its_softc *); >>> +static uint32_t its_get_devid(device_t); >>>=20 >>> static int its_cmd_send(struct gic_v3_its_softc *, struct >>> its_cmd_desc *); >>> @@ -133,6 +135,23 @@ const char *its_ptab_type[] =3D { >>> [GITS_BASER_TYPE_RES7] =3D "Reserved (7)", >>> }; >>>=20 >>> +/* >>> + * Vendor specific quirks. >>> + * One needs to add appropriate entry to its_quirks[] >>> + * table if the imlementation varies from the generic ARM ITS. >>> + */ >>> + >>> +/* Cavium ThunderX PCI devid acquire function */ >>> +static uint32_t its_get_devid_thunder(device_t); >>> + >>> +static const struct its_quirks its_quirks[] =3D { >>> + { >>> + .cpuid =3D CPU_ID_RAW(CPU_IMPL_CAVIUM, >>> CPU_PART_THUNDER, 0, 0), >>> + .cpuid_mask =3D CPU_IMPL_MASK | CPU_PART_MASK, >>> + .devid_func =3D its_get_devid_thunder, >>> + }, >>> +}; >>> + >>> static struct gic_v3_its_softc *its_sc; >>>=20 >>> #define gic_its_read(sc, len, reg) \ >>> @@ -1300,7 +1319,7 @@ its_device_alloc_locked(struct gic_v3_it >>> if (newdev !=3D NULL) >>> return (newdev); >>>=20 >>> - devid =3D PCI_DEVID(pci_dev); >>> + devid =3D its_get_devid(pci_dev); >>>=20 >>> /* There was no previously created device. Create one now */ >>> newdev =3D malloc(sizeof(*newdev), M_GIC_V3_ITS, (M_WAITOK | >>> M_ZERO)); @@ -1353,6 +1372,73 @@ its_device_asign_lpi_locked(struct >>> gic_v its_dev->lpis.lpi_free); >>> its_dev->lpis.lpi_free--; >>> } >>> + >>> +/* >>> + * ITS quirks. >>> + * Add vendor specific PCI devid function here. >>> + */ >>> +static uint32_t >>> +its_get_devid_thunder(device_t pci_dev) >>> +{ >>> + int bsf; >>> + int pem; >>> + uint32_t bus; >>> + >>> + bus =3D pci_get_bus(pci_dev); >>> + >>> + bsf =3D PCI_RID(pci_get_bus(pci_dev), pci_get_slot(pci_dev), >>> + pci_get_function(pci_dev)); >>> + >>> + /* ECAM is on bus=3D0 */ >>> + if (bus =3D=3D 0) { >>> + return ((pci_get_domain(pci_dev) << >>> PCI_RID_DOMAIN_SHIFT) | >>> + bsf); >>> + /* PEM otherwise */ >>> + } else { >>> + /* PEM number is equal to domain */ >>> + pem =3D pci_get_domain(pci_dev); >>=20 >> But what is a PEM number? >=20 > PEM =3D=3D PCI-E MAC. > This is the number of root complex. >=20 >>=20 >>> + >>> + /* Hardcode appropriate PEM numbers */ >>> + if (pem < 3 ) >>> + return ((0x1 << PCI_RID_DOMAIN_SHIFT) | bsf); >>> + >>> + if (pem < 6 ) >>> + return ((0x3 << PCI_RID_DOMAIN_SHIFT) | bsf); >>> + >>> + if (pem < 9 ) >>> + return ((0x9 << PCI_RID_DOMAIN_SHIFT) | bsf); >>> + >>> + if (pem < 12 ) >>> + return ((0xB << PCI_RID_DOMAIN_SHIFT) | bsf); >>=20 >> What do these magic numbers mean? >=20 > This is a domain portion of PCI device ID passed by the HW along with > the transaction to memory. > In that case the methodology differs from the genuine (default in this > driver) ARM implementation and it is Thunder-specific. >=20 >>=20 >>> + } >>> + >>> + return (0); >>> +} >>> + >>=20 >> Andrew >> _______________________________________________ >> svn-src-all@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/svn-src-all >> To unsubscribe, send any mail to = "svn-src-all-unsubscribe@freebsd.org" --Apple-Mail=_BC466D0C-78A5-4437-812A-B519F59F46FE Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJVrnJQAAoJEGwc0Sh9sBEA/gQQAJERGWu5K1VvJgHiRVBnC70e B+5P4dxg2ANK0qHe4e2IZBbK8RLi70NGKHUkxsNf13eR3Tnu+g0sd+KDeUmdx3Pc 4J+GLGF190bDFG4MY8BGvGgQJnxcZrsFNDA4j0Rr9Brq4ymxY+0wHz7OxWwFn/JF q15iThqHIpUEPjld8/R3s/dV9NHih6k+l3O05EHzId4n3Ub6CjicVT7bZrJpZ0KH RxPHUKRgWHD8ps+0SGJ6tWCnxs8+AE0zI1CrRMEzVtCT3vIJfxyXbKjFqYIhz+q4 f43Zr+CrpLyzMlllAXPkVqI0X6MorhZuwIjrJY82TJBQ6Ha2VnyckLthcZAoNt0t bQwd1fKuiUHtVT9ut9gQ2DniWSOp4Nhit+37AK8I96RPhLnWsVcPHkU9lv80iR/A diBZZSDpxwYyzlyNK+4O3ZTle0CeLJVmZ/QHXyUBlPSJ1bDIG37us09ko6iyNOZh InYxuytaWY4rNrF0VvZH3ZYVpnPav9VOtQH6MI+L57Oe7p6Jl3b546hAMbpUNzeJ 0B9+gfqtV8qO/cCSw9FC8ofvBBtK6Bztn2/C62vH+UtwCRCsao8Y3Y4J5D45gJb7 Z02xQO6+jOuNAH+Is+QEc/+qVBgakuzeSqknOZ46ANpzjSzjItXbB9GHiK5R4IP1 /W7KVPz50o/H+OTwzMGF =Hu8R -----END PGP SIGNATURE----- --Apple-Mail=_BC466D0C-78A5-4437-812A-B519F59F46FE--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?90C4DA24-6770-4DB5-AF87-20CB8E812657>