Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Mar 2018 09:01:20 -0800
From:      John Baldwin <jhb@freebsd.org>
To:        Andrew Turner <andrew@freebsd.org>
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
Message-ID:  <2340744.aoyHCQxNFB@ralph.baldwin.cx>
In-Reply-To: <201803071047.w27AlRiY032946@repo.freebsd.org>
References:  <201803071047.w27AlRiY032946@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2340744.aoyHCQxNFB>