From nobody Mon May 09 12:34:27 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 C8FF21ADA357;
Mon, 9 May 2022 12:34:27 +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 4KxgbR54HDz3jsD;
Mon, 9 May 2022 12:34:27 +0000 (UTC)
(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
t=1652099667;
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=wx4QTMaeGMiffBNGYI0LBQeji49ESDalfSJFCviTv+4=;
b=wudZnuzL6+D9pn3i8kXnLsn2ORQcR55dpebJNCnqwO9CjFCiAIycwj5fGZybqmzugoo8o7
qXoK07jli6Zs333Qajvv8JnGsHQDT0RAsXqmfwO5JwXehAZVlbErob1+/2Rm025naYnEqw
dzbrQ9fwmJUq4QbateTDH51TvC89i1V43Oc2lDQxXaz7B/+79mEzJ1kfFJuT1XV808teHl
TXZHHx/Pjl3xJQZcj4UUnAC5/xl/tSunZ/YhmiiTblXg1fqjsZqeI5bcQDidqfLV7YQ2mU
1DnvHLM9nAu03vahBLavFp5cx+qp3irXuKt/8ahCpe03nr8SIKv2tN+pg/wm6Q==
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 89AA1113A3;
Mon, 9 May 2022 12:34:27 +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 249CYRJH031918;
Mon, 9 May 2022 12:34:27 GMT
(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 249CYRoC031917;
Mon, 9 May 2022 12:34:27 GMT
(envelope-from git)
Date: Mon, 9 May 2022 12:34:27 GMT
Message-Id: <202205091234.249CYRoC031917@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: f224006fe1b3 - main - Allocate resources selectively. One of the SMMU interrupt lines (priq) is optional and may be ommited in FDT.
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: br
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: f224006fe1b367452fc3f2d36b32411cbbe11101
Auto-Submitted: auto-generated
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
s=dkim; t=1652099667;
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=wx4QTMaeGMiffBNGYI0LBQeji49ESDalfSJFCviTv+4=;
b=bZBTPV/nvcRlNO4k0jhOTorKJmm2gS+kLxA1CS564aSrOKOrjYuFuT715jUNOY8iJ9fua3
oACjVnL8zrjuD2vQDggltrGpS5hxqwPsBaTxUZmpL0U30jnEXjgSogUlGkZaUXxGFH0MLl
lL25yYjMlepvWb9zYEePcGwKrMI+Jov5dL0h1/mdMT854nFNZYHVyiWITnMYDT+42+fCIp
lVlrZUof3kETT9UXheQjizrPOTt9Qu5Qq/vzdyLFLBujC42P3F3s8CYNmAPEZzwImU+83W
i+CgkEbeCkvcRyN1u+ZpHWjyVhwM+tV9jFuTOCoirITIsA+nGHYXqbaumkYGbg==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652099667; a=rsa-sha256; cv=none;
b=ncqGkiQYBVhoRiY68aTIp7z6ZZRo7648HRqgrZnNuayaa5io6Jnt4nTu6tlTr8JrVBKajS
qpwR7HK6YKUs0RLDWYmdQN/BTvTMeHOJASJ5Jkj9HqJ107N0FEiuI63/mweqIiyOLFuI0E
bmDfAn0GOGMEitGs0wMInycfhXqXdW0lWMFthuiKRorbO3Ib6HN9pZkKbhR/0bbBh/0xgk
iQy6fUQ+wSNSk0dW1NEPhHfdS4SwaZpU+c6gWdEiopZHeQLPacTFXQECWJ9qtyL0X4o+u0
Qwv2G9Likm5T9HDZKM1ybWE4WsBC4YTFVgRm/8luSfG4LGbByj/1n5+JrESxIQ==
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=f224006fe1b367452fc3f2d36b32411cbbe11101
commit f224006fe1b367452fc3f2d36b32411cbbe11101
Author: Ruslan Bukin
AuthorDate: 2022-05-09 12:30:37 +0000
Commit: Ruslan Bukin
CommitDate: 2022-05-09 12:30:37 +0000
Allocate resources selectively.
One of the SMMU interrupt lines (priq) is optional and may be ommited in FDT.
Tested on ARM Morello Board, which has three SMMU units: first two have four
interrupt lines, last one has three interrupt lines.
Sponsored by: UKRI
---
sys/arm64/iommu/smmu.c | 8 +-----
sys/arm64/iommu/smmu_acpi.c | 39 ++++++++++++++++++++++++++
sys/arm64/iommu/smmu_fdt.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+), 7 deletions(-)
diff --git a/sys/arm64/iommu/smmu.c b/sys/arm64/iommu/smmu.c
index f3e434c02e3f..e1197db34375 100644
--- a/sys/arm64/iommu/smmu.c
+++ b/sys/arm64/iommu/smmu.c
@@ -152,7 +152,7 @@ __FBSDID("$FreeBSD$");
static struct resource_spec smmu_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ SYS_RES_IRQ, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 1, RF_ACTIVE },
+ { SYS_RES_IRQ, 1, RF_ACTIVE | RF_OPTIONAL },
{ SYS_RES_IRQ, 2, RF_ACTIVE },
{ SYS_RES_IRQ, 3, RF_ACTIVE },
RESOURCE_SPEC_END
@@ -1547,12 +1547,6 @@ smmu_attach(device_t dev)
mtx_init(&sc->sc_mtx, device_get_nameunit(sc->dev), "smmu", MTX_DEF);
- error = bus_alloc_resources(dev, smmu_spec, sc->res);
- if (error) {
- device_printf(dev, "Couldn't allocate resources.\n");
- return (ENXIO);
- }
-
error = smmu_setup_interrupts(sc);
if (error) {
bus_release_resources(dev, smmu_spec, sc->res);
diff --git a/sys/arm64/iommu/smmu_acpi.c b/sys/arm64/iommu/smmu_acpi.c
index 6ddbb0138c87..bd59ad398e6a 100644
--- a/sys/arm64/iommu/smmu_acpi.c
+++ b/sys/arm64/iommu/smmu_acpi.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include
#include
#include
+#include
#include
#include
#include
@@ -192,6 +193,7 @@ smmu_acpi_attach(device_t dev)
struct iommu_unit *iommu;
uintptr_t priv;
int err;
+ int rid;
sc = device_get_softc(dev);
sc->dev = dev;
@@ -204,6 +206,43 @@ smmu_acpi_attach(device_t dev)
device_printf(sc->dev, "%s: features %x\n",
__func__, sc->features);
+ rid = 0;
+ sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+ RF_ACTIVE);
+ if (sc->res[0] == NULL) {
+ device_printf(dev, "Can't allocate memory resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ /*
+ * Interrupt lines are "eventq", "priq", "cmdq-sync", "gerror".
+ */
+
+ rid = 0;
+ sc->res[1] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+ if (sc->res[1] == NULL) {
+ device_printf(dev, "Can't allocate eventq IRQ resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ rid = 2;
+ sc->res[3] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+ if (sc->res[3] == NULL) {
+ device_printf(dev, "Can't allocate cmdq-sync IRQ resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ rid = 3;
+ sc->res[4] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+ if (sc->res[4] == NULL) {
+ device_printf(dev, "Can't allocate gerror IRQ resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
err = smmu_attach(dev);
if (err != 0)
goto error;
diff --git a/sys/arm64/iommu/smmu_fdt.c b/sys/arm64/iommu/smmu_fdt.c
index 86cf0f9fd0cf..f2d441fe8340 100644
--- a/sys/arm64/iommu/smmu_fdt.c
+++ b/sys/arm64/iommu/smmu_fdt.c
@@ -82,11 +82,79 @@ smmu_fdt_attach(device_t dev)
struct smmu_softc *sc;
struct smmu_unit *unit;
struct iommu_unit *iommu;
+ phandle_t node;
int err;
+ int rid;
sc = device_get_softc(dev);
sc->dev = dev;
+ node = ofw_bus_get_node(dev);
+
+ rid = 0;
+ sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+ RF_ACTIVE);
+ if (sc->res[0] == NULL) {
+ device_printf(dev, "Can't allocate memory resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ /*
+ * Interrupt lines are "eventq", "priq", "cmdq-sync", "gerror".
+ */
+
+ err = ofw_bus_find_string_index(node, "interrupt-names", "eventq",
+ &rid);
+ if (err != 0) {
+ device_printf(dev, "Can't get eventq IRQ.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ sc->res[1] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+ if (sc->res[1] == NULL) {
+ device_printf(dev, "Can't allocate eventq IRQ resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ /*
+ * sc->res[2] is reserved for priq IRQ. It is optional and not used
+ * by the SMMU driver. This IRQ line may or may not be provided by
+ * hardware.
+ */
+
+ err = ofw_bus_find_string_index(node, "interrupt-names", "cmdq-sync",
+ &rid);
+ if (err != 0) {
+ device_printf(dev, "Can't get cmdq-sync IRQ.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ sc->res[3] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+ if (sc->res[3] == NULL) {
+ device_printf(dev, "Can't allocate cmdq-sync IRQ resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ err = ofw_bus_find_string_index(node, "interrupt-names", "gerror",
+ &rid);
+ if (err != 0) {
+ device_printf(dev, "Can't get gerror IRQ.\n");
+ err = ENXIO;
+ goto error;
+ }
+
+ sc->res[4] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
+ if (sc->res[4] == NULL) {
+ device_printf(dev, "Can't allocate gerror IRQ resource.\n");
+ err = ENXIO;
+ goto error;
+ }
+
err = smmu_attach(dev);
if (err != 0)
goto error;