From nobody Sun Mar 5 20:28:04 2023 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 4PVCvS5WRdz3tw31; Sun, 5 Mar 2023 20:28:04 +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 4PVCvS4SnMz3vqF; Sun, 5 Mar 2023 20:28:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678048084; 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=b5ih/vl/XyGaOi+rnIhOWFPa0ou6wFJJuGV9pktmp/s=; b=RrRl67GBwTuT0qmvpD40x8YhwwC6cyrnOlph69dfp5UBd/3LgqABaQVrkxRWHOrkXUDck9 NHCjlBLPJchn7IGhBgBsRqns/S9siTxoI2nRb7PkUXiGD4MZAP8j3Eas8QqXnMwxfcj5Q4 dWiSd+8l8/dIFuzl+MhVMOS8PfYr/6ZuQarUqHjxwC4YyKE3LlcbBZOmwRhqwuCinOAwRZ G9o48oH3m3zPvlkpAgTIh9KqibaQDp/aA4BPAFQOFgQl/XDOh12OCB0aYxXG6MJliBEsdN 9KxSGmYiA0s3Fb5VmhumxRHvgP85ITv52hTOdYalLQApWEdL/WJhtSpXfCTNFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678048084; 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=b5ih/vl/XyGaOi+rnIhOWFPa0ou6wFJJuGV9pktmp/s=; b=rBdFVzOXGeG7NbgnU4hoWOts1NnZsMW+EFNbaw7pBHjnfvlBwiJs2GuJQwTDHBI5L7PaL+ 72hP9AcSlzjoor7zWSNek8PUS/K0atxX+ZhXxsWKQsOs7JWBz6BvbtYNc3NQ2y3zAG3l9f EGFD7mikaAdImPQHyldaDPnpaTIanFgvUngxrk2O/mp/D04zk46kuXrZSrcTG9cprr0cFI WsK2IgWnB/fBbFbMILiYmgRMXR/ABqCrKNLfM+ec12NVmvIpPjUn2y2yjwA/JwoEOqqIvd l2zTslbYisQYUnbTWHYuM2u2wkaS9nkFSrF3zlufavP9O67kXmX1XiogTcz0Iw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678048084; a=rsa-sha256; cv=none; b=jhUL90nn7HZx0/NmQ9CshqrQudTv8wHwsU285OWDb8ldTt+xOUZdBngbNPSB+zCkjL3RVN Bhr/TuJ5h8ItoGEp1iHUKDdWw4xxPiD8CWndofurWn1hrtqmyLCLTIZp+V6yewIC4Q0N4T yWTxC4+3YU+gi576HC9nfNjJ6NXcOHHVnsQC2q3j8Eo/wUWOLA+mjiN64wqb47lybKXwr5 TSbWpUrh6/zovXqvtA9tWWT89DzdEUqlt8ytVIfkLgpmvA3E28FzWGXCvoNm6ZxIimw7EF 8CVNgoI4cMpzfoyhb8sg7c6AF+CwQpOBIj55RhDIER6DMzhqPcUGuwBgzrkejA== 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 4PVCvS3Z4YzZB3; Sun, 5 Mar 2023 20:28:04 +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 325KS4RZ039272; Sun, 5 Mar 2023 20:28:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 325KS4Tx039270; Sun, 5 Mar 2023 20:28:04 GMT (envelope-from git) Date: Sun, 5 Mar 2023 20:28:04 GMT Message-Id: <202303052028.325KS4Tx039270@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: 5a91529479b4 - main - Support non-posted MMIO on arm64 with 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a91529479b4180ce031046640febc6fa3ec02a3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=5a91529479b4180ce031046640febc6fa3ec02a3 commit 5a91529479b4180ce031046640febc6fa3ec02a3 Author: Andrew Turner AuthorDate: 2023-03-05 12:35:40 +0000 Commit: Andrew Turner CommitDate: 2023-03-05 20:17:21 +0000 Support non-posted MMIO on arm64 with FDT To allow hardware to work around a broken memory bus where we need to support the nonposted-mmio flag. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D34333 --- sys/arm64/arm64/nexus.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c index 50604fd22e98..d07965433919 100644 --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #ifdef FDT #include +#include #include #include "ofw_bus_if.h" #endif @@ -92,6 +93,7 @@ static int nexus_attach(device_t); #ifdef FDT static device_probe_t nexus_fdt_probe; static device_attach_t nexus_fdt_attach; +static bus_activate_resource_t nexus_fdt_activate_resource; #endif #ifdef DEV_ACPI static device_probe_t nexus_acpi_probe; @@ -366,9 +368,10 @@ nexus_get_bus_tag(device_t bus __unused, device_t child __unused) } static int -nexus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) +nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid, + struct resource *r, int flags) { + struct resource_map_request args; struct resource_map map; int err; @@ -382,7 +385,10 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid, case SYS_RES_IOPORT: case SYS_RES_MEMORY: if ((rman_get_flags(r) & RF_UNMAPPED) == 0) { - err = nexus_map_resource(bus, child, type, r, NULL, + resource_init_map_request(&args); + if ((flags & BUS_SPACE_MAP_NONPOSTED) != 0) + args.memattr = VM_MEMATTR_DEVICE_NP; + err = nexus_map_resource(bus, child, type, r, &args, &map); if (err != 0) { rman_deactivate_resource(r); @@ -402,6 +408,13 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid, return (0); } +static int +nexus_activate_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + return (nexus_activate_resource_flags(dev, child, type, rid, r, 0)); +} + static struct resource_list * nexus_get_reslist(device_t dev, device_t child) { @@ -497,6 +510,9 @@ static device_method_t nexus_fdt_methods[] = { DEVMETHOD(device_probe, nexus_fdt_probe), DEVMETHOD(device_attach, nexus_fdt_attach), + /* Bus interface */ + DEVMETHOD(bus_activate_resource, nexus_fdt_activate_resource), + /* OFW interface */ DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr), @@ -529,6 +545,39 @@ nexus_fdt_attach(device_t dev) return (nexus_attach(dev)); } +static int +nexus_fdt_activate_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + phandle_t node, parent; + int flags; + + flags = 0; + switch (type) { + case SYS_RES_MEMORY: + case SYS_RES_IOPORT: + /* + * If the fdt parent has the nonposted-mmio property we + * need to use non-posted IO to access the device. When + * we find this property set the BUS_SPACE_MAP_NONPOSTED + * flag to be passed to bus_space_map. + */ + node = ofw_bus_get_node(child); + if (node != -1) { + parent = OF_parent(node); + if (parent != -1 && + OF_hasprop(parent, "nonposted-mmio")) { + flags |= BUS_SPACE_MAP_NONPOSTED; + } + } + break; + default: + break; + } + + return (nexus_activate_resource_flags(bus, child, type, rid, r, flags)); +} + static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells, pcell_t *intr)