From owner-dev-commits-src-all@freebsd.org Thu Sep 16 14:43:06 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 7D96C67B6E6 for ; Thu, 16 Sep 2021 14:43:06 +0000 (UTC) (envelope-from mw@semihalf.com) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 4H9KZK4ztyz3Msg for ; Thu, 16 Sep 2021 14:43:05 +0000 (UTC) (envelope-from mw@semihalf.com) Received: by mail-wm1-x32f.google.com with SMTP id j17-20020a05600c1c1100b002e754875260so4669269wms.4 for ; Thu, 16 Sep 2021 07:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=i7mBcaDkSn94e8RP7FCI1AZ1+h9Wj6YJO4UatMLd9gA=; b=XVxibuxFx0+P/uadulasGk46jM5jPLv8033zKJun26WUhLmLA9P4AFJcw7gXle7w1i dDPl4CIE9+sl6q/9bTyMIjFD8KVSHL54ju8yGxDh0i9MchLVNLib8IvcKLsxEDqklEWh nJffUlSPIYFHPWF+icc+2OWLwX5rbQEQube8pchjraz4Kf9++GHCKYowFWGECiki/H0v 530MhjbD2VrtZRN+ICQEQArYdcdzGAwiOVVOjjPZxUI6iBDihzyIyUb/Bn3c1eLOkE6n aPsbwlAI05uZSWYo07E+wp/zD5pdFsGPN8/q1C0tZ2R61cL7HwiXA1Avy+hmDtw7lTln Pv4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=i7mBcaDkSn94e8RP7FCI1AZ1+h9Wj6YJO4UatMLd9gA=; b=gJa/lNRX3PRY38lVFO0GXHQ7+EYVaXKAESJoRrK2tabr6h7xEI0pIDAwngkY7tCcVF 7c9ACQJNzwwcvZG+Px3wRUQO0EgKivUdLGA4sN8ZSDUq7XB849F1iajRTISPcZ0dhJAH NdRIQUYCXonBqa3gwj5DqgC+P94WMd1UxspVSlRv17v84jg2/3EhNCW0GtC9C6N+QMb9 1KEWa4K3C2/k+TVpxlJhrlklq+/eC8asoI5ImtYPpv2UO9gS2fbzm0Jictk3pcRWjh1F o6gtaHRtH2KSBliNv5QjjngcAEdupx3+uSOHJFJ1T8/IjrMpP54jVMLv2/fr1X04K/JT sR2w== X-Gm-Message-State: AOAM533x5Ct9isASoa1wA3VVj2DUWyWANoIfzlRvvWulkHwWZuVC808y W3+abGNyVceAwWF5uB71GvdOd3hyVs4jqOmXTowF6w== X-Google-Smtp-Source: ABdhPJwPVnNs/MXRlhMME3LSpZzaULVaRvdAmiF2BiyLu+vDuMTIsgulT8YRo8ioDH3eI6OqW4d5/jeHGOSph5NlFRA= X-Received: by 2002:a05:600c:3656:: with SMTP id y22mr10425673wmq.58.1631803377766; Thu, 16 Sep 2021 07:42:57 -0700 (PDT) MIME-Version: 1.0 References: <202109151318.18FDIppM059878@gitrepo.freebsd.org> In-Reply-To: From: Marcin Wojtas Date: Thu, 16 Sep 2021 16:42:45 +0200 Message-ID: Subject: Re: git: 2de4c7f6d087 - main - pci_host_generic: Add Synopsys Designware PCIe controller quirk To: Jessica Clarke Cc: Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4H9KZK4ztyz3Msg X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=semihalf-com.20210112.gappssmtp.com header.s=20210112 header.b=XVxibuxF; dmarc=none; spf=none (mx1.freebsd.org: domain of mw@semihalf.com has no SPF policy when checking 2a00:1450:4864:20::32f) smtp.mailfrom=mw@semihalf.com X-Spamd-Result: default: False [-3.28 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[semihalf-com.20210112.gappssmtp.com:s=20210112]; FREEFALL_USER(0.00)[mw]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; RCVD_TLS_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-all@freebsd.org]; DMARC_NA(0.00)[semihalf.com]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[semihalf-com.20210112.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.98)[-0.977]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::32f:from]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all] 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: Thu, 16 Sep 2021 14:43:06 -0000 =C5=9Br., 15 wrz 2021 o 15:21 Jessica Clarke napisa=C5= =82(a): > > On 15 Sep 2021, at 14:18, Marcin Wojtas wrote: > > > > The branch main has been updated by mw: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D2de4c7f6d08798fb62695829= 07155703d1ab5ef4 > > > > commit 2de4c7f6d08798fb6269582907155703d1ab5ef4 > > Author: Pawel Anikiel > > AuthorDate: 2021-09-13 14:59:40 +0000 > > Commit: Marcin Wojtas > > CommitDate: 2021-09-15 13:17:40 +0000 > > > > pci_host_generic: Add Synopsys Designware PCIe controller quirk > > > > 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. > > > > 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(+) > > > > diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_gene= ric.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); > > > > 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_gene= ric.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; > > }; > > > > +/* Quirks */ > > +#define PCIE_ECAM_DESIGNWARE_QUIRK (1 << 0) > > + > > DECLARE_CLASS(generic_pcie_core_driver); > > > > 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 > > > > +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 */ > > > > 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); > > } > > > > +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); > > > > + 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? > Indeed, thanks for noticing. I'll commit an update right away. Thanks, Marcin