From owner-svn-src-all@freebsd.org Wed Mar 7 17:17:21 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B71BF41C21; Wed, 7 Mar 2018 17:17:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E8478820BA; Wed, 7 Mar 2018 17:17:20 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 2D66110AFAD; Wed, 7 Mar 2018 12:17:14 -0500 (EST) From: John Baldwin To: Andrew Turner Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r330575 - in head/sys: conf dev/acpica dev/pci Date: Wed, 07 Mar 2018 09:01:20 -0800 Message-ID: <2340744.aoyHCQxNFB@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201803071047.w27AlRiY032946@repo.freebsd.org> References: <201803071047.w27AlRiY032946@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Wed, 07 Mar 2018 12:17:14 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2018 17:17:21 -0000 On Wednesday, March 07, 2018 10:47:27 AM Andrew Turner wrote: > Author: andrew > Date: Wed Mar 7 10:47:27 2018 > New Revision: 330575 > URL: https://svnweb.freebsd.org/changeset/base/330575 > > Log: > Add an acpi attachment to the pci_host_generic driver and have the ACPI > bus provide it with its needed memory resources. > > This allows us to use PCIe on the ThunderX2 and, with a previous version > of the patch, on the SoftIron 3000 with ACPI. > > Obtained from: ABT Systems Ltd > Sponsored by: The FreeBSD Foundation > Sponsored by: DARPA, AFRL > Sponsored by: Cavium (Hardware) > Differential Revision: https://reviews.freebsd.org/D8767 > > Added: > head/sys/dev/pci/pci_host_generic_acpi.c (contents, props changed) > Modified: > head/sys/conf/files.arm64 > head/sys/dev/acpica/acpi.c > > Modified: head/sys/conf/files.arm64 > ============================================================================== > --- head/sys/conf/files.arm64 Wed Mar 7 09:58:36 2018 (r330574) > +++ head/sys/conf/files.arm64 Wed Mar 7 10:47:27 2018 (r330575) > @@ -171,6 +171,8 @@ crypto/blowfish/bf_enc.c optional crypto | ipsec | ips > crypto/des/des_enc.c optional crypto | ipsec | ipsec_support | netsmb > dev/acpica/acpi_bus_if.m optional acpi > dev/acpica/acpi_if.m optional acpi > +dev/acpica/acpi_pci_link.c optional acpi pci > +dev/acpica/acpi_pcib.c optional acpi pci > dev/ahci/ahci_generic.c optional ahci > dev/axgbe/if_axgbe.c optional axgbe > dev/axgbe/xgbe-desc.c optional axgbe > @@ -191,6 +193,7 @@ dev/neta/if_mvneta.c optional neta mdio mii > dev/ofw/ofw_cpu.c optional fdt > dev/ofw/ofwpci.c optional fdt pci > dev/pci/pci_host_generic.c optional pci > +dev/pci/pci_host_generic_acpi.c optional pci acpi > dev/pci/pci_host_generic_fdt.c optional pci fdt > dev/psci/psci.c optional psci > dev/psci/psci_arm64.S optional psci > > Modified: head/sys/dev/acpica/acpi.c > ============================================================================== > --- head/sys/dev/acpica/acpi.c Wed Mar 7 09:58:36 2018 (r330574) > +++ head/sys/dev/acpica/acpi.c Wed Mar 7 10:47:27 2018 (r330575) > @@ -1883,6 +1883,29 @@ acpi_enable_pcie(void) > alloc++; > } > } > +#elif defined(__aarch64__) > +static void > +acpi_enable_pcie(device_t child, int segment) > +{ > + ACPI_TABLE_HEADER *hdr; > + ACPI_MCFG_ALLOCATION *alloc, *end; > + ACPI_STATUS status; > + > + status = AcpiGetTable(ACPI_SIG_MCFG, 1, &hdr); > + if (ACPI_FAILURE(status)) > + return; > + > + end = (ACPI_MCFG_ALLOCATION *)((char *)hdr + hdr->Length); > + alloc = (ACPI_MCFG_ALLOCATION *)((ACPI_TABLE_MCFG *)hdr + 1); > + while (alloc < end) { > + if (alloc->PciSegment == segment) { > + bus_set_resource(child, SYS_RES_MEMORY, 0, > + alloc->Address, 0x10000000); > + return; > + } > + alloc++; > + } > +} > #endif > > /* > @@ -1974,6 +1997,9 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, voi > { > ACPI_DEVICE_INFO *devinfo; > struct acpi_device *ad; > +#ifdef __aarch64__ > + int segment; > +#endif > struct acpi_prw_data prw; > ACPI_OBJECT_TYPE type; > ACPI_HANDLE h; > @@ -2076,6 +2102,13 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, voi > ad->ad_cls_class = strtoul(devinfo->ClassCode.String, > NULL, 16); > } > +#ifdef __aarch64__ > + if ((devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0) { > + if (ACPI_SUCCESS(acpi_GetInteger(handle, "_SEG", &segment))) { > + acpi_enable_pcie(child, segment); > + } > + } > +#endif > AcpiOsFree(devinfo); > } > break; This logic probably belongs in the attach routine of the pcib driver rather than in MD #ifdef's in acpi.c. I still think we should be using acpi_pcib_acpi.c on arm64. IIRC all that is required is using a layer of indirection for PCI config access (using the existing pcib_if.m methods in the parent of acpi0 would work for this). -- John Baldwin