From nobody Mon Mar 07 11:19:57 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BBFFC1A06FB3; Mon, 7 Mar 2022 11:19:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KBwwY5MDFz4WPn; Mon, 7 Mar 2022 11:19:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646651998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OetIjaAtfbwrDVYtkdM1HLMk8KkCmXg537tqPfcqyWI=; b=OZP6eTBG2h+ZLzuH82hXdcx8OqAxO3jOpmtNACfApQeW8dn5UqsIDlyPiaafqU7gOAjpdW 6mciB8VrNmLEJimDZKgdysEQrcXslWtUq0UODZKK8ppl7kPD6nGJyeoUiogTeMgisi1K/w p/arW2xU2oGM4DeglJMZQxim0ryv5B9OG0FrrZNooKCKEJyNBuly+Q4Rei/vTL5YXGmx5h 3x5FPpFQ2qootqzib18BxLcW0sE6sGJXUwmb4ylvYwiTenxqKgY2Etrbuf3Quja9xo94yx Nxlh8JO7YMMTKZ+qvPRyoo/HcwmUCc1gyskJ94dRFq/DS8NLEjToBcHL6aXFTA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6E9DC26C71; Mon, 7 Mar 2022 11:19:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 227BJvhg084521; Mon, 7 Mar 2022 11:19:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 227BJvAC084520; Mon, 7 Mar 2022 11:19:57 GMT (envelope-from git) Date: Mon, 7 Mar 2022 11:19:57 GMT Message-Id: <202203071119.227BJvAC084520@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 393538e35d26 - stable/13 - pci_host_generic: Add Synopsys Designware PCIe controller quirk List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 393538e35d2656746a9254bf21ec86074dddb56b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646651998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OetIjaAtfbwrDVYtkdM1HLMk8KkCmXg537tqPfcqyWI=; b=XebY9HQZBqC1yIxpV5zXoasIIdV4I6XaGzKiDugMIMvXDaajVks3rutm7uTHPA8Rsd9DP7 62z5uDH1qauD1jd7OelELCABHAbQ7sFKHHT3idWaJ1xjjeIx8Pzm7d86sqy7VSPRBZTByv EU60/nV1wyi7tgQIYgPOOnuekAOH2l6I9MgLhgYpZff7YriOEGOCXO6pb1+mP21Q4nCN2r 9zTHG8T4s1Hyoyg4qsNN0+CkvzywtFEGlYwIcPPwNZqGW4FhXN+nGzrTdK9B/RBkKB3wfL y1rdPB0oGiYPll9j0H2hYBtRKApzuIBp5n7HTN2OZHt6nxSheCjprzC1OyToGQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646651998; a=rsa-sha256; cv=none; b=qcmc5rj9Ki5qcJgIM00Ahe6UjChEnXPImhjFLqX0qXvFcW96afbMAmL+tx9ZazlV4FrzVJ weOB3xk99/6O8Q7SR0ZBUkTLgHLR0pczcI0pawYrAmxZR0RcQuwBcFKYLtA/AsZjzE79Ki DliSTzWwWz8RtZ60cclA83eKzJI8LTS1Hv/00y9BKIxVSkVzGzZ+4fPwomrIOaGdVM8xcX hXejWQj8sMgn5ybrDnf5azW5Qli1W94TsF0TQ/fkMW8k7QKj/ougD6f7+sTwn+0KrFNgJl W+xUaMlqH4jroCuM9XjvU0oIklPR7MBSIEBNOLsNK9/SyGKLiofQGQAzcPQb9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=393538e35d2656746a9254bf21ec86074dddb56b commit 393538e35d2656746a9254bf21ec86074dddb56b Author: Pawel Anikiel AuthorDate: 2021-09-13 14:59:40 +0000 Commit: Marcin Wojtas CommitDate: 2022-03-07 11:19:28 +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 (cherry picked from commit 2de4c7f6d08798fb6269582907155703d1ab5ef4) --- 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_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 == 0 && slot > 0) + return (~0U); offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg); t = 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; }; +/* 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[] = { + { "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 = 0; pci_acpi_quirks[i].quirks; i++) { + if (memcmp(hdr->OemId, pci_acpi_quirks[i].oem_id, + ACPI_OEM_ID_SIZE) != 0) + continue; + if (memcmp(hdr->OemTableId, pci_acpi_quirks[i].oem_table_id, + ACPI_OEM_TABLE_ID_SIZE) != 0) + continue; + sc->base.quirks |= 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 = 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 48e032ad4389..3e3aee0d172a 100644 --- a/sys/dev/pci/pci_host_generic_fdt.c +++ b/sys/dev/pci/pci_host_generic_fdt.c @@ -154,6 +154,13 @@ pci_host_generic_setup_fdt(device_t dev) if (error != 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"); + sc->base.quirks |= PCIE_ECAM_DESIGNWARE_QUIRK; + } + ofw_bus_setup_iinfo(node, &sc->pci_iinfo, sizeof(cell_t)); return (0);