From owner-dev-commits-src-all@freebsd.org Wed Sep 15 13:21:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2E4FE67EA7C for ; Wed, 15 Sep 2021 13:21:08 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H8gpD0clLz3l89 for ; Wed, 15 Sep 2021 13:21:08 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f41.google.com with SMTP id u15so3876171wru.6 for ; Wed, 15 Sep 2021 06:21:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=tI08zHBmt3DSlD8uL1cSShXRCTjTmaiHhAu/CspMGv0=; b=aCndYojcNPzp7Lf04BiYyLuGP+HtgccQjPdbnBr8m3FQpIZWn+mCqY0mmv4obslLt7 GymuXLhG6XRsCWduR+iXhL3GfaQ1Wrt9EfMdSIyS0ayNRQgteL0B2sxpQgEZh/fvSdEw FOqTwdPM7mcF7n2rOuYLse4rCtbilFl0Z3IVW/JovEw+AuJM7uxhjBgea+RH9AoUOszB aVKTsWDCprhhYy9HN4lT0Fbseh3tP/JHM2ZecijGKh1oceKuwRWmxrR4GfpntKcEedaQ iE1ZoOzXBzOx4ieaDKHGipiS/KB5e8le+6grqqxGDAwbBjjIzz7ttaSw9T5psBVxtYTJ rzHQ== X-Gm-Message-State: AOAM533XIKLOasxxYwdn4E1/XKu9zoWa0lXmvSqv8IiXmGx2JZn9RYdY YMnWvECJNadQf7D6Pe6Wv0zjng== X-Google-Smtp-Source: ABdhPJwNqPRFdP1nIHMiGkWpAk2T1rU18DlX/18PrsdUmeJ1ktE4jV3hXLAAH5fZALVKeWtzntCsow== X-Received: by 2002:adf:f507:: with SMTP id q7mr5235096wro.7.1631712060928; Wed, 15 Sep 2021 06:21:00 -0700 (PDT) Received: from smtpclient.apple (global-5-143.nat-2.net.cam.ac.uk. [131.111.5.143]) by smtp.gmail.com with ESMTPSA id j23sm15477wmo.14.2021.09.15.06.21.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Sep 2021 06:21:00 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: 2de4c7f6d087 - main - pci_host_generic: Add Synopsys Designware PCIe controller quirk From: Jessica Clarke In-Reply-To: <202109151318.18FDIppM059878@gitrepo.freebsd.org> Date: Wed, 15 Sep 2021 14:20:59 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <202109151318.18FDIppM059878@gitrepo.freebsd.org> To: Marcin Wojtas X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Queue-Id: 4H8gpD0clLz3l89 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 13:21:08 -0000 On 15 Sep 2021, at 14:18, Marcin Wojtas wrote: >=20 > The branch main has been updated by mw: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D2de4c7f6d08798fb6269582907155703= d1ab5ef4 >=20 > commit 2de4c7f6d08798fb6269582907155703d1ab5ef4 > Author: Pawel Anikiel > AuthorDate: 2021-09-13 14:59:40 +0000 > Commit: Marcin Wojtas > CommitDate: 2021-09-15 13:17:40 +0000 >=20 > pci_host_generic: Add Synopsys Designware PCIe controller quirk >=20 > Due to the quirky nature of the Synopsys Designware PCIe IP, > the type 0 configuration is broadcast and whatever device > is plugged into slot, will appear at each 32 device > positions of bus0. Mitigate the issue by filtering out > duplicated devices on this bus for both DT and ACPI cases. >=20 > Reviewed by: mw > Sponsored by: Semihalf > MFC: after 3 weeks > Differential revision: https://reviews.freebsd.org/D31887 > --- > sys/dev/pci/pci_host_generic.c | 2 ++ > sys/dev/pci/pci_host_generic.h | 4 ++++ > sys/dev/pci/pci_host_generic_acpi.c | 33 = +++++++++++++++++++++++++++++++++ > sys/dev/pci/pci_host_generic_fdt.c | 7 +++++++ > 4 files changed, 46 insertions(+) >=20 > diff --git a/sys/dev/pci/pci_host_generic.c = b/sys/dev/pci/pci_host_generic.c > index 0c45f5d316ed..22b3ccdc17b1 100644 > --- a/sys/dev/pci/pci_host_generic.c > +++ b/sys/dev/pci/pci_host_generic.c > @@ -185,6 +185,8 @@ generic_pcie_read_config(device_t dev, u_int bus, = u_int slot, > if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || > (reg > PCIE_REGMAX)) > return (~0U); > + if ((sc->quirks & PCIE_ECAM_DESIGNWARE_QUIRK) && bus =3D=3D 0 && = slot > 0) > + return (~0U); >=20 > offset =3D PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, = reg); > t =3D sc->bst; > diff --git a/sys/dev/pci/pci_host_generic.h = b/sys/dev/pci/pci_host_generic.h > index 36a12b9559ba..20117cbe32e3 100644 > --- a/sys/dev/pci/pci_host_generic.h > +++ b/sys/dev/pci/pci_host_generic.h > @@ -85,8 +85,12 @@ struct generic_pcie_core_softc { > device_t dev; > bus_space_handle_t ioh; > bus_dma_tag_t dmat; > + uint32_t quirks; > }; >=20 > +/* Quirks */ > +#define PCIE_ECAM_DESIGNWARE_QUIRK (1 << 0) > + > DECLARE_CLASS(generic_pcie_core_driver); >=20 > int pci_host_generic_core_attach(device_t); > diff --git a/sys/dev/pci/pci_host_generic_acpi.c = b/sys/dev/pci/pci_host_generic_acpi.c > index 763a84d2fd53..3c32abc5007a 100644 > --- a/sys/dev/pci/pci_host_generic_acpi.c > +++ b/sys/dev/pci/pci_host_generic_acpi.c > @@ -89,6 +89,21 @@ __FBSDID("$FreeBSD$"); > #define PROPS_CELL_SIZE 1 > #define PCI_ADDR_CELL_SIZE 2 >=20 > +static struct { > + char oem_id[ACPI_OEM_ID_SIZE + 1]; > + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1]; > + uint32_t quirks; > +} pci_acpi_quirks[] =3D { > + { "MRVL ", "CN9130 ", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { "MRVL ", "CN913X ", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { "MVEBU ", "ARMADA7K", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { "MVEBU ", "ARMADA8K", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { "MVEBU ", "CN9130 ", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { "MVEBU ", "CN9131 ", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { "MVEBU ", "CN9132 ", PCIE_ECAM_DESIGNWARE_QUIRK }, > + { 0 }, > +}; > + > /* Forward prototypes */ >=20 > static int generic_pcie_acpi_probe(device_t dev); > @@ -170,6 +185,23 @@ = pci_host_generic_acpi_parse_resource(ACPI_RESOURCE *res, void *arg) > return (AE_OK); > } >=20 > +static void > +pci_host_acpi_get_oem_quirks(struct generic_pcie_acpi_softc *sc, > + ACPI_TABLE_HEADER *hdr) > +{ > + int i; > + > + for (i =3D 0; pci_acpi_quirks[i].quirks; i++) { > + if (memcmp(hdr->OemId, pci_acpi_quirks[i].oem_id, > + ACPI_OEM_ID_SIZE) !=3D 0) > + continue; > + if (memcmp(hdr->OemTableId, = pci_acpi_quirks[i].oem_table_id, > + ACPI_OEM_TABLE_ID_SIZE) !=3D 0) > + continue; > + sc->base.quirks |=3D pci_acpi_quirks[i].quirks; > + } > +} > + > static int > pci_host_acpi_get_ecam_resource(device_t dev) > { > @@ -209,6 +241,7 @@ pci_host_acpi_get_ecam_resource(device_t dev) > sc->base.bus_start, sc->base.bus_end); > return (ENXIO); > } > + pci_host_acpi_get_oem_quirks(sc, hdr); > } else { > status =3D acpi_GetInteger(handle, "_CBA", &val); > if (ACPI_SUCCESS(status)) > diff --git a/sys/dev/pci/pci_host_generic_fdt.c = b/sys/dev/pci/pci_host_generic_fdt.c > index 91ffaf7357b9..249637019137 100644 > --- a/sys/dev/pci/pci_host_generic_fdt.c > +++ b/sys/dev/pci/pci_host_generic_fdt.c > @@ -151,6 +151,13 @@ pci_host_generic_setup_fdt(device_t dev) > if (error !=3D 0) > return (error); >=20 > + if (ofw_bus_is_compatible(dev, "marvell,armada8k-pcie-ecam") || > + ofw_bus_is_compatible(dev, "socionext,synquacer-pcie-ecam") = || > + ofw_bus_is_compatible(dev, "snps,dw-pcie-ecam")) { > + device_set_desc(dev, "Synopsys DesignWare PCIe = Controller"); It seems inconsistent to set this for _fdt but not _acpi? Jess