Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4044164pxm; Tue, 1 Mar 2022 10:05:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2S7X1TUlHzAfkk1JcZKAP7vNE+2D+PR8liYSmf+ugCPmqUnK5qcMp3+zT+97mp5a7SmAF X-Received: by 2002:a05:6402:42c9:b0:407:f86c:44e7 with SMTP id i9-20020a05640242c900b00407f86c44e7mr25789401edc.230.1646157937420; Tue, 01 Mar 2022 10:05:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646157937; cv=none; d=google.com; s=arc-20160816; b=CMn6B8Orc1upxU17Gh8BWVktgOdi4l4faJsDFv6ENkEL28Eyg/BJD9F/VzBnXt6u4L 1SkYv6k5Q4LoUnHjTPxUgHsPyh0XjLik8P6DjImCWSOM3i+FuIbz2+zxpzOCaAG4UQnT jccVn13A3KjM6Qom5f8EIHCYZFHYzLWKpZLS3H7FmlIl9rohHX0rjKwPKXYV0RNHIm+g PkFUmFRnEEYGtx7XWg8260WABmCZbNWb7QvNS/P8yYP1yAb/jJVCZ8VWYEE/NIoZdfsH Q6gcfN++HB6IrHPeYsAct0wYOFDqYbNdBiRmYKVrM/yX8gki7d4DvFogFM1VXjSAxY7R qVbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6sRdRmuArPB9M+DZhEXPrB8b5Pq6lEbN63VVfh3955E=; b=F+gyRqRkNpbI9wPQw3v1ufo1yoEMLz/7lmCZixXd1qxj8kW6yLPogo0QI0/9CfuloX 6auWPvMQydotma5GXSwJ7gdAk6QNbOMAoGQ4kxU5US4jAacpgh7jFccsdOo2oNXRZxBL ztxU/M9ayBP8FQEdsNyT4ub70FdgKnQrx18YVcC+rjX02OKGU4Kl9tnnkskXpSxis3TJ 3oH/pf7OKB1MlPgkq/kPqiyBxLCbjRxxXOfw+qYRBi+3hqS8eu+JNvPOmr1wKZ8g9DZj bggaTPpcYQu22iw4SMf9/8IEftewJYqsURC4hS/EY6OILws6/FgatWzwAF4XIW7QN9/8 ke6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=hghlNdvK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a17090658c300b006cf034a8f28si9991631ejs.147.2022.03.01.10.05.11; Tue, 01 Mar 2022 10:05:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=hghlNdvK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236142AbiCAQQp (ORCPT + 99 others); Tue, 1 Mar 2022 11:16:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233033AbiCAQQS (ORCPT ); Tue, 1 Mar 2022 11:16:18 -0500 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C0BE91370; Tue, 1 Mar 2022 08:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6sRdRmuArPB9M+DZhEXPrB8b5Pq6lEbN63VVfh3955E=; b=hghlNdvKgM7ALxY2nJrCubp8BI XPNh06HpEJya/ZJJK4ZhiiqygiGORv5OIM5sLeb8wEZlMUUJtmoP17eV3WW2ZFqPn3kA8+WBKzz4M +koy7DKYiq6WlfWT6zMJ4t3h1dM2M0rzlLpJLd7iskKEw8P5rAWyAfLR9IlcMRr3fgFN4FtybcHkh P0I3h3d6kY4YKr8iITrY9D+DcfXwmgH0/Wh31pJV3MBG8CqxDosDy08yB1nC7ZZY4UXxdW3gUGZDe pnDBPIFHftenPECJFbOVvgcpe2HeLj92e06W7eqWthuyaQAcxZ/yETzOOj0ovGMaYtnU2HEB/iANK 7BhbbcNw==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=toshino.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nP59q-0003Z8-LR; Tue, 01 Mar 2022 18:15:26 +0200 From: cyndis@kapsi.fi To: thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, robh+dt@kernel.org, krzysztof.kozlowski@canonical.com Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mikko Perttunen Subject: [PATCH v4 2/9] gpu: host1x: Add context bus Date: Tue, 1 Mar 2022 18:14:48 +0200 Message-Id: <20220301161455.4037062-3-cyndis@kapsi.fi> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220301161455.4037062-1-cyndis@kapsi.fi> References: <20220301161455.4037062-1-cyndis@kapsi.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikko Perttunen The context bus is a "dummy" bus that contains struct devices that correspond to IOMMU contexts assigned through Host1x to processes. Even when host1x itself is built as a module, the bus is registered in built-in code so that the built-in ARM SMMU driver is able to reference it. Signed-off-by: Mikko Perttunen --- v4: * Export bus as GPL --- drivers/gpu/Makefile | 3 +-- drivers/gpu/host1x/Kconfig | 5 +++++ drivers/gpu/host1x/Makefile | 1 + drivers/gpu/host1x/context_bus.c | 31 ++++++++++++++++++++++++++++++ include/linux/host1x_context_bus.h | 15 +++++++++++++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/host1x/context_bus.c create mode 100644 include/linux/host1x_context_bus.h diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile index 835c88318cec..8997f0096545 100644 --- a/drivers/gpu/Makefile +++ b/drivers/gpu/Makefile @@ -2,7 +2,6 @@ # drm/tegra depends on host1x, so if both drivers are built-in care must be # taken to initialize them in the correct order. Link order is the only way # to ensure this currently. -obj-$(CONFIG_TEGRA_HOST1X) += host1x/ -obj-y += drm/ vga/ +obj-y += host1x/ drm/ vga/ obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/ obj-$(CONFIG_TRACE_GPU_MEM) += trace/ diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig index 6815b4db17c1..1861a8180d3f 100644 --- a/drivers/gpu/host1x/Kconfig +++ b/drivers/gpu/host1x/Kconfig @@ -1,8 +1,13 @@ # SPDX-License-Identifier: GPL-2.0-only + +config TEGRA_HOST1X_CONTEXT_BUS + bool + config TEGRA_HOST1X tristate "NVIDIA Tegra host1x driver" depends on ARCH_TEGRA || (ARM && COMPILE_TEST) select DMA_SHARED_BUFFER + select TEGRA_HOST1X_CONTEXT_BUS select IOMMU_IOVA help Driver for the NVIDIA Tegra host1x hardware. diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile index d2b6f7de0498..c891a3e33844 100644 --- a/drivers/gpu/host1x/Makefile +++ b/drivers/gpu/host1x/Makefile @@ -18,3 +18,4 @@ host1x-y = \ hw/host1x07.o obj-$(CONFIG_TEGRA_HOST1X) += host1x.o +obj-$(CONFIG_TEGRA_HOST1X_CONTEXT_BUS) += context_bus.o diff --git a/drivers/gpu/host1x/context_bus.c b/drivers/gpu/host1x/context_bus.c new file mode 100644 index 000000000000..b0d35b2bbe89 --- /dev/null +++ b/drivers/gpu/host1x/context_bus.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2021, NVIDIA Corporation. + */ + +#include +#include + +struct bus_type host1x_context_device_bus_type = { + .name = "host1x-context", +}; +EXPORT_SYMBOL_GPL(host1x_context_device_bus_type); + +static int __init host1x_context_device_bus_init(void) +{ + int err; + + if (!of_machine_is_compatible("nvidia,tegra186") && + !of_machine_is_compatible("nvidia,tegra194") && + !of_machine_is_compatible("nvidia,tegra234")) + return 0; + + err = bus_register(&host1x_context_device_bus_type); + if (err < 0) { + pr_err("bus type registration failed: %d\n", err); + return err; + } + + return 0; +} +postcore_initcall(host1x_context_device_bus_init); diff --git a/include/linux/host1x_context_bus.h b/include/linux/host1x_context_bus.h new file mode 100644 index 000000000000..72462737a6db --- /dev/null +++ b/include/linux/host1x_context_bus.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021, NVIDIA Corporation. All rights reserved. + */ + +#ifndef __LINUX_HOST1X_CONTEXT_BUS_H +#define __LINUX_HOST1X_CONTEXT_BUS_H + +#include + +#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS +extern struct bus_type host1x_context_device_bus_type; +#endif + +#endif -- 2.35.0