From nobody Mon Apr 24 15:51:17 2023 X-Original-To: dev-commits-src-main@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 4Q4qP13Jydz470f3; Mon, 24 Apr 2023 15:51:17 +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 4Q4qP12lm6z3x53; Mon, 24 Apr 2023 15:51:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682351477; 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=T5sTAJqj6aVnEZwI2wQA0NklPlLm0RbIpleeUBEWOMM=; b=BKvh2eoTw39sa2p4u6uXn8u9a/DH2TFmlbZ3nlcTLZS6CACMcCDaToiHxCFBsJd0qMTFK8 tPHB9HQGT1dBRXYlWweXcblSIPY4aXiFjNNLS6V/j2Ra6qBwN2Td8SpifEa3Hza3jZp2WX H127bTpmCO4gMdZNiJvS8OienV8s3MzCJrj1kZMFbFwT9Ev+R5E1kZZFukJ5lwzafNjbSM qLKGDAQLAmMVii0pDHZIcqDX3/AF/L7+sgGih0Aizvm1OIsbgX0TivOuc+E+M7+dT7wTzG D+zfpr4WDxp8SE6U0XEnEoKbYWFdySfy+J8rlZprp5uvINgiMwn1ytoNj1YeZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682351477; 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=T5sTAJqj6aVnEZwI2wQA0NklPlLm0RbIpleeUBEWOMM=; b=eq/UGXtyX7jT0ym9BpXKX1NxYl+e7uD/4jmwdDkAjSiTeiwv21oqw1D6LaZRgekjFQ0k+e z4SKwGmRLi087CA/+4dtFELuNBr8zKwLVbG07EAbCovHpFB0m/YZAsz3UINmsOsn7mjdBB MNjEOqDc+7NboijFGZRwqcHrJ9uwZoxcHr2UYJxgcCpsUS/lAV84c5Y2RJIef8WaOoG5Ok f6i3NINDsHcSluFcJBoQaoG1VqWB9qFwJKz0DssqxvPHdfaDwrdwWiUX0iwvfrnvIeZba4 WeseHLyqz60Yrh1eO3StSDXN1mPrGz2OgrKq7PVztIl9BanS+kINJhDuVo1PIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682351477; a=rsa-sha256; cv=none; b=GgmYfEXELhcO2TRJo5wdMGZMkgI+GPcXoyH8vo2U7KXtv3G1zTznIjX6++eSDExfv5vLmn NYCdpOfEEjcx0G1bBFgaRbJvBMqh7wUiK8rEPTjUGj/EUMfexBW4KChXqO+qMKHyOWAZvP DpddFgXHlGyR28hMhltZ5TJ78hMYF+yRVec/yk25ch5z3dn57bYkTxdeBLqVBOI5BBcTr+ 6qrYYCC9RqnKsH4ai8f0sJoiznWfUINqIqLokSHNUsutu5UeUAGk+qot4kHpOoQZ/ogS80 Xuf7ScysctWzZ5S2iG2EKzPff6mD2eZx4l3KJh5IuXW5FQn81VJozb6C+nrKlg== 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 4Q4qP11rKQzWRB; Mon, 24 Apr 2023 15:51:17 +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 33OFpHbP096454; Mon, 24 Apr 2023 15:51:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33OFpHnX096453; Mon, 24 Apr 2023 15:51:17 GMT (envelope-from git) Date: Mon, 24 Apr 2023 15:51:17 GMT Message-Id: <202304241551.33OFpHnX096453@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: c94e4d91da37 - main - Clean up PCI DEN0115 driver probing List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c94e4d91da37f6216f3c9cd128e508fd334f06e8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=c94e4d91da37f6216f3c9cd128e508fd334f06e8 commit c94e4d91da37f6216f3c9cd128e508fd334f06e8 Author: Andrew Turner AuthorDate: 2023-04-24 14:35:56 +0000 Commit: Andrew Turner CommitDate: 2023-04-24 15:34:21 +0000 Clean up PCI DEN0115 driver probing Rather than checking for the SMCCC version check if the PCI_VERSION call returns a valid version. Sponsored by: Arm Ltd --- sys/dev/pci/pci_host_generic_den0115.c | 43 ++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/sys/dev/pci/pci_host_generic_den0115.c b/sys/dev/pci/pci_host_generic_den0115.c index 08cb77cea22c..d620a755a1ca 100644 --- a/sys/dev/pci/pci_host_generic_den0115.c +++ b/sys/dev/pci/pci_host_generic_den0115.c @@ -52,13 +52,14 @@ static device_attach_t pci_host_acpi_smccc_attach; static pcib_read_config_t pci_host_acpi_smccc_read_config; static pcib_write_config_t pci_host_acpi_smccc_write_config; +static bool pci_host_acpi_smccc_pci_version(uint32_t *); + static int pci_host_acpi_smccc_probe(device_t dev) { ACPI_DEVICE_INFO *devinfo; struct resource *res; ACPI_HANDLE h; - uint32_t smccc_version; int rid, root; if (acpi_disabled("pcib") || (h = acpi_get_handle(dev)) == NULL || @@ -80,17 +81,13 @@ pci_host_acpi_smccc_probe(device_t dev) return (ENXIO); } - /* Check the SMCCC is at least v1.1 */ - smccc_version = smccc_get_version(); - if (SMCCC_VERSION_MAJOR(smccc_version) > 1 || - (SMCCC_VERSION_MAJOR(smccc_version) == 1 && - SMCCC_VERSION_MINOR(smccc_version) == 0)) { - device_set_desc(dev, - "ARM PCI Firmware config space host controller"); - return (BUS_PROBE_SPECIFIC); + /* Check for the PCI_VERSION call */ + if (!pci_host_acpi_smccc_pci_version(NULL)) { + return (ENXIO); } - return (EINVAL); + device_set_desc(dev, "ARM PCI Firmware config space host controller"); + return (BUS_PROBE_SPECIFIC); } #define SMCCC_PCI_VERSION \ @@ -134,11 +131,28 @@ pci_host_acpi_smccc_has_feature(uint32_t pci_func_id) return (true); } +static bool +pci_host_acpi_smccc_pci_version(uint32_t *versionp) +{ + struct arm_smccc_res result; + + if (psci_callfn(SMCCC_PCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &result) < 0) { + return (false); + } + + if (versionp != NULL) { + *versionp = result.a0; + } + + return (true); +} + static int pci_host_acpi_smccc_attach(device_t dev) { struct generic_pcie_acpi_softc *sc; struct arm_smccc_res result; + uint32_t version; int end, start; int error; @@ -147,17 +161,16 @@ pci_host_acpi_smccc_attach(device_t dev) MPASS(psci_callfn != NULL); - /* Check there is a version */ - if (psci_callfn(SMCCC_PCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &result) < 0) { + /* Read the version */ + if (!pci_host_acpi_smccc_pci_version(&version)) { device_printf(dev, - "Failed to read the SMCCC PCI version: %lx\n", result.a0); + "Failed to read the SMCCC PCI version\n"); return (ENXIO); } if (bootverbose) { device_printf(dev, "Firmware v%d.%d\n", - SMCCC_PCI_MAJOR((uint32_t)result.a0), - SMCCC_PCI_MINOR((uint32_t)result.a0)); + SMCCC_PCI_MAJOR(version), SMCCC_PCI_MINOR(version)); } if (!pci_host_acpi_smccc_has_feature(SMCCC_PCI_READ) ||