From nobody Mon May 9 19:14:17 2022
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 D14F81ABDD97;
Mon, 9 May 2022 19:14: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 4KxrSn5X0Jz3mn2;
Mon, 9 May 2022 19:14:17 +0000 (UTC)
(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
t=1652123657;
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=b2KA0/XBf/o3jKrVBeV3M+L617l3qfxgHox1RVuxxzM=;
b=GXb2LNZ+QFnUo9poZpCSxpkWD7KFSsKHr2dt9kjxTENqQGA2xoF4M/3RF57UChyvPxH4tY
zjTpUWcTV1wMmEaooJ57G1Nvm20Yx8LbT0n/7e+i/cGYH6AeObCLQO5J9NcK8JMDmJ5vSy
8+5lOy6zoI9qMzZyRoX0dv3pUqZ97qSw2rLa7z7E49/H4S1wSmPUEYEoeu++OUDh1qtjz2
y9q+5C1kZEK6uSHIzo2ZeAl66S+9UfUgpqy3jx885+kk6eUiucAD3URYl14LzbYVM5FsTD
RwkZ2pE1iS0ju/PAHuUNITXx1dBQuHEoRdDemGCNft+m6RWG+dy5R/Q4sRdlvg==
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 9DC4E16C2A;
Mon, 9 May 2022 19:14: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 249JEHMF071662;
Mon, 9 May 2022 19:14:17 GMT
(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 249JEHaJ071661;
Mon, 9 May 2022 19:14:17 GMT
(envelope-from git)
Date: Mon, 9 May 2022 19:14:17 GMT
Message-Id: <202205091914.249JEHaJ071661@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
dev-commits-src-main@FreeBSD.org
From: Ruslan Bukin
Subject: git: b7fca06bbf3f - main - Split-out SID-getting code to a separate functions. Also ensure we are dealing with PCI-class devices.
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: br
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: b7fca06bbf3f24313cb513842ad0078df43d211a
Auto-Submitted: auto-generated
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
s=dkim; t=1652123657;
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=b2KA0/XBf/o3jKrVBeV3M+L617l3qfxgHox1RVuxxzM=;
b=jqHgZkb6nN1ibUp6ga8P0kOyHXnkIbjtidJDRXhcrcmpRDV9egmrPbW5jOa2QhKc7coQbR
tIi9GNR/73PnaFgX51/bKqqQt3is19WPezG+ThM3XOm6UOex+j6CPEFRU+nrL2xkpBIyED
EMUPjVy7U0mcDQn8yi3uH3r24smMd5epwjRXCywcguU2cxS+6zzadIb7JkrFix+Yp9TeCJ
UI/CihRgzN1zwUkpeIoTKp7ldVkiQHo5QGA4yD221q4XbeKCT7JXFJv5yKN2D3bbSZYmpC
hqSYXGyrLei+gsS65HnR2gY1xTaXQl2dAdNyKijZWEEXxm5r7Pxjd9knTyoPuQ==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652123657; a=rsa-sha256; cv=none;
b=fEVoE7fVmun6a5hlnAf6qX4j6obXoUE7iCwbu1LvQRiWohHGLpQEoqAaRicZE5RigOheNR
OaDvnhPIONNaO38o5HZhUIVdAG/TW2DIdYeWqz2NhivVjfpmN+gjUCWukJzVJZtwVeyjqq
gnYIgXsOgxhFUck5PLYqhHrO+4tdmhxDb5K9VrbRES51gGoS+UJbCSbKdMbdVmxQFacbBA
0k380pT5HEnf1rS6Q7zvwHzwrOdRKPIEcr4VaLn/Oau3uYAkD6mZgUuLRda5VlymY17yvU
kvc8lLKMrO9SSYBF/2/NMtyUPYUrA+qDqYXtQbDomh2fDdk8R2ipegaTskLflw==
ARC-Authentication-Results: i=1;
mx1.freebsd.org;
none
X-ThisMailContainsUnwantedMimeParts: N
The branch main has been updated by br:
URL: https://cgit.FreeBSD.org/src/commit/?id=b7fca06bbf3f24313cb513842ad0078df43d211a
commit b7fca06bbf3f24313cb513842ad0078df43d211a
Author: Ruslan Bukin
AuthorDate: 2022-05-09 19:08:01 +0000
Commit: Ruslan Bukin
CommitDate: 2022-05-09 19:13:57 +0000
Split-out SID-getting code to a separate functions.
Also ensure we are dealing with PCI-class devices.
Sponsored by: UKRI
---
sys/arm64/iommu/smmu.c | 57 ++++++++++++++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 13 deletions(-)
diff --git a/sys/arm64/iommu/smmu.c b/sys/arm64/iommu/smmu.c
index e1197db34375..20971a2d7e41 100644
--- a/sys/arm64/iommu/smmu.c
+++ b/sys/arm64/iommu/smmu.c
@@ -1760,6 +1760,42 @@ smmu_set_buswide(device_t dev, struct smmu_domain *domain,
return (0);
}
+#ifdef DEV_ACPI
+static int
+smmu_pci_get_sid_acpi(device_t child, u_int *sid0)
+{
+ uint16_t rid;
+ u_int xref;
+ int seg;
+ int err;
+ int sid;
+
+ seg = pci_get_domain(child);
+ rid = pci_get_rid(child);
+
+ err = acpi_iort_map_pci_smmuv3(seg, rid, &xref, &sid);
+ if (err == 0)
+ *sid0 = sid;
+
+ return (err);
+}
+#endif
+
+#ifdef FDT
+static int
+smmu_pci_get_sid_fdt(device_t child, u_int *sid0)
+{
+ struct pci_id_ofw_iommu pi;
+ int err;
+
+ err = pci_get_id(child, PCI_ID_OFW_IOMMU, (uintptr_t *)&pi);
+ if (err == 0)
+ *sid0 = pi.id;
+
+ return (err);
+}
+#endif
+
static struct iommu_ctx *
smmu_ctx_alloc(device_t dev, struct iommu_domain *iodom, device_t child,
bool disabled)
@@ -1767,28 +1803,23 @@ smmu_ctx_alloc(device_t dev, struct iommu_domain *iodom, device_t child,
struct smmu_domain *domain;
struct smmu_softc *sc;
struct smmu_ctx *ctx;
-#ifdef DEV_ACPI
- uint16_t rid;
- u_int xref;
- int seg;
-#else
- struct pci_id_ofw_iommu pi;
-#endif
+ devclass_t pci_class;
u_int sid;
int err;
sc = device_get_softc(dev);
domain = (struct smmu_domain *)iodom;
+ pci_class = devclass_find("pci");
+ if (device_get_devclass(device_get_parent(child)) != pci_class)
+ return (NULL);
+
#ifdef DEV_ACPI
- seg = pci_get_domain(child);
- rid = pci_get_rid(child);
- err = acpi_iort_map_pci_smmuv3(seg, rid, &xref, &sid);
+ err = smmu_pci_get_sid_acpi(child, &sid);
#else
- err = pci_get_id(child, PCI_ID_OFW_IOMMU, (uintptr_t *)&pi);
- sid = pi.id;
+ err = smmu_pci_get_sid_fdt(child, &sid);
#endif
- if (err != 0)
+ if (err)
return (NULL);
if (sc->features & SMMU_FEATURE_2_LVL_STREAM_TABLE) {