Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6372037pxb; Mon, 8 Nov 2021 07:34:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhqTN+mmGN1Syy7bls0dJOBVXZ/Rx0sdYDVBIWqEsTxVt2tGx5X5rjZwec5Ml8QI+TYOlb X-Received: by 2002:a17:907:7e88:: with SMTP id qb8mr127463ejc.535.1636385645871; Mon, 08 Nov 2021 07:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636385645; cv=none; d=google.com; s=arc-20160816; b=ga8Ht25hIGo4YmcD+nHnAmnO9e3/TD4PPz+Gyc2UUxxsdVb9O/9Y/KaxeAYm/3GQPU xCir8VAjRUd2JOBNnSA81daKQYtJlA4McKRkGy3TRIombM4gJFY2Qxtt1SiIBDtLdRvp I7YVv8um742x2LVKyPkRJ2OYGKrPNUbHYRDooG8TQLz10luz0fka3TcK1NkXhbDVetJg lIjIVevEz92B3n281ACNbtCl52UQ411vJQ6Cf8ENbKNX1gTteNkNFXEm41NImnuSbc6s DZ6zxYJjTjiqBspcEfXufEwpliGlnoRhj8WaODfwPXo8qxwMCJr4Zszla1Aa4qoBtPGg wmtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=i/cmFLJWXjRGackmQbyW+VCsyR/4I0WIJ6EqrdSA6JY=; b=dEf6a5mB2S1g+BgHQtIHK8Qi+G6Okbe9OrfafNXuxJl2GmL9V3ZEVyATv+pkxNuA7Y o+wucYirl1B8DpFEz5lsCT2QN8TC1yEo85qLA2hrQ8jsQSYTi9Q9tIzgHCABu5UHVPPa Vd9zENNV7Mz/l2gcQtCG/GZoZ9vDrGIcoBRry8BqDIWkxG2yN3CusZe7r+KKEEz+bzth GjdBSJMkIFGSIs9g9nBoMFxakGTJx1MC9uVqBmen3WOeZe8w/Dq08Li6jNm8jVbfyU1w EqIaUA98sTYHZIIuUb6b9HtXm3jecWrnhU77BY5bXzv9MqaSSGKXRM5Zelm6y4rTKNZs q3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=TgVDqLVO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si7254128edr.319.2021.11.08.07.33.38; Mon, 08 Nov 2021 07:34:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=TgVDqLVO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238299AbhKHKjq (ORCPT + 99 others); Mon, 8 Nov 2021 05:39:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238180AbhKHKjo (ORCPT ); Mon, 8 Nov 2021 05:39:44 -0500 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AA6EC061570; Mon, 8 Nov 2021 02:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: 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=i/cmFLJWXjRGackmQbyW+VCsyR/4I0WIJ6EqrdSA6JY=; b=TgVDqLVO+s5RobZKj0e0tc5fNy sQ7s4SFC8WtG6elM+NAEv4mjxfpoy7JVFvonGPrL7zQr/ez3Zy+k/cZUaqJiRecRCcNi2P7VbkE8F ka3tcQvpeAovYzNEd+HkVHsCfpaMi0A8MmEWp93+1bfLdOoI1b6w4GoA214JujO2mNRUBzstQdeGa bLpBKQN1PyJKDS+X8rDt5TmKrMO9LNSjG+242s85JwTjTX7Vrv0uE+3eFdT/Lgf1H4RdXtzWOLNPt n83LDUWPlVc+rTMI2qPSbTvt1fc9jEFAk7Sd+yh6crFCPnwJUgWt/1tb+cKxoGcaWvVttLk2IRflv xP/M3HYw==; Received: from dsl-hkibng22-54f986-236.dhcp.inet.fi ([84.249.134.236] helo=[192.168.1.10]) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1mk21D-0008PS-Od; Mon, 08 Nov 2021 12:36:51 +0200 Subject: Re: [PATCH v2 0/8] Host1x context isolation support To: Mikko Perttunen , thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robh+dt@kernel.org, robin.murphy@arm.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 References: <20210916143302.2024933-1-mperttunen@nvidia.com> From: Mikko Perttunen Message-ID: <10de82cf-27a5-8890-93a5-0e58c74e5bcc@kapsi.fi> Date: Mon, 8 Nov 2021 12:36:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210916143302.2024933-1-mperttunen@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 84.249.134.236 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/16/21 5:32 PM, Mikko Perttunen wrote: > Hi all, > > *** > New in v2: > > Added support for Tegra194 > Use standard iommu-map property instead of custom mechanism > *** > > this series adds support for Host1x 'context isolation'. Since > when programming engines through Host1x, userspace can program in > any addresses it wants, we need some way to isolate the engines' > memory spaces. Traditionally this has either been done imperfectly > with a single shared IOMMU domain, or by copying and verifying the > programming command stream at submit time (Host1x firewall). > > Since Tegra186 there is a privileged (only usable by kernel) > Host1x opcode that allows setting the stream ID sent by the engine > to the SMMU. So, by allocating a number of context banks and stream > IDs for this purpose, and using this opcode at the beginning of > each job, we can implement isolation. Due to the limited number of > context banks only each process gets its own context, and not > each channel. > > This feature also allows sharing engines among multiple VMs when > used with Host1x's hardware virtualization support - up to 8 VMs > can be configured with a subset of allowed stream IDs, enforced > at hardware level. > > To implement this, this series adds a new host1x context bus, which > will contain the 'struct device's corresponding to each context > bank / stream ID, changes to device tree and SMMU code to allow > registering the devices and using the bus, as well as the Host1x > stream ID programming code and support in TegraDRM. > > Device tree bindings are not updated yet pending consensus that the > proposed changes make sense. > > Thanks, > Mikko > > Mikko Perttunen (8): > gpu: host1x: Add context bus > gpu: host1x: Add context device management code > gpu: host1x: Program context stream ID on submission > iommu/arm-smmu: Attach to host1x context device bus > arm64: tegra: Add Host1x context stream IDs on Tegra186+ > drm/tegra: falcon: Set DMACTX field on DMA transactions > drm/tegra: vic: Implement get_streamid_offset > drm/tegra: Support context isolation > > arch/arm64/boot/dts/nvidia/tegra186.dtsi | 12 ++ > arch/arm64/boot/dts/nvidia/tegra194.dtsi | 12 ++ > drivers/gpu/Makefile | 3 +- > drivers/gpu/drm/tegra/drm.h | 2 + > drivers/gpu/drm/tegra/falcon.c | 8 + > drivers/gpu/drm/tegra/falcon.h | 1 + > drivers/gpu/drm/tegra/submit.c | 13 ++ > drivers/gpu/drm/tegra/uapi.c | 34 ++++- > drivers/gpu/drm/tegra/vic.c | 38 +++++ > drivers/gpu/host1x/Kconfig | 5 + > drivers/gpu/host1x/Makefile | 2 + > drivers/gpu/host1x/context.c | 174 ++++++++++++++++++++++ > drivers/gpu/host1x/context.h | 27 ++++ > drivers/gpu/host1x/context_bus.c | 31 ++++ > drivers/gpu/host1x/dev.c | 12 +- > drivers/gpu/host1x/dev.h | 2 + > drivers/gpu/host1x/hw/channel_hw.c | 52 ++++++- > drivers/gpu/host1x/hw/host1x06_hardware.h | 10 ++ > drivers/gpu/host1x/hw/host1x07_hardware.h | 10 ++ > drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 ++ > include/linux/host1x.h | 21 +++ > include/linux/host1x_context_bus.h | 15 ++ > 22 files changed, 488 insertions(+), 9 deletions(-) > create mode 100644 drivers/gpu/host1x/context.c > create mode 100644 drivers/gpu/host1x/context.h > create mode 100644 drivers/gpu/host1x/context_bus.c > create mode 100644 include/linux/host1x_context_bus.h > IOMMU/DT folks, any thoughts about this approach? The patches that are of interest outside of Host1x/TegraDRM specifics are patches 1, 2, 4, and 5. Thanks, Mikko