Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3021086iog; Mon, 27 Jun 2022 07:36:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s/Y7drtAL5RUOb3eKcXGmQ1n54rUMAfdCipRrU2mpkJVhecY8xhcOb9OF0Kw8Qa85QAO7A X-Received: by 2002:a05:6a00:23ca:b0:525:28b4:9e3b with SMTP id g10-20020a056a0023ca00b0052528b49e3bmr14916405pfc.43.1656340603058; Mon, 27 Jun 2022 07:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656340603; cv=none; d=google.com; s=arc-20160816; b=SNhDJaw/M7Zeyj9/lexCkRHzETr8do9OWQgILrmxnIbYyQNN4x0nJKLqTjDTqLS57j abJnAzxvjSngEEbpR2u9VFVsZ89eOOXy5ZQUXs7sIHoRwYnnKE67uf5ijGZduu3qSj71 67mJPDHLhvt9fGEKdP0NlG+inGpm1nroqrIPa4wxAiikfxiwPLsKbYaWmQug38+279ki c02za1pVbo6dBxLNMQUCQxP9+Za/Teysrowb3mBv/jLaxwtVgM7KmY3bfPrQqZJhkrt6 n1Oc2m5YczY2GXS+NO/R9NwNC932ss1NEKpMq16aF1KDU+Y8NE/XLowDOfuh/ZWn01+e BSnQ== 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=jqNVkhlKQgqXtLeAWprMxZosE+nkqym2SEmCMhLQNlc=; b=FfIb06VWYWieU5W58aKyv1ZPX+9N5+VflNA3cQ1PQpJZDAHhAebtCT1FIq04wzquwu EJx6wk/EQInkZlfx9CnmywSw/kaExdDuRy3GsztS3a4OEwHNlzuYKpZmo0SpIu98XA2O 4zsvm11LM5piLikhiv5cewkCDvE3WeuUqfKZFMkDOuFHQZi9m0MF7uRf1LRP10s/4a8a j4Q4hwtd2/+INojmKt89pWpdbhhznOBGNr/KWlMGepN8Mtycn0JZkvh2+l+xq0RchnPl j7SS5yqWamOg440tTs5q+nGUlnAi8kqOr1o7gMsT313qsfUjHYCqnR/dF/FgT0OYoRaD Czbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=UKrJgi8m; 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 y191-20020a638ac8000000b0040ce2432b6csi13212106pgd.586.2022.06.27.07.36.29; Mon, 27 Jun 2022 07:36:43 -0700 (PDT) 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=UKrJgi8m; 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 S237243AbiF0OVj (ORCPT + 99 others); Mon, 27 Jun 2022 10:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237012AbiF0OUo (ORCPT ); Mon, 27 Jun 2022 10:20:44 -0400 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA9F411464; Mon, 27 Jun 2022 07:20:41 -0700 (PDT) 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=jqNVkhlKQgqXtLeAWprMxZosE+nkqym2SEmCMhLQNlc=; b=UKrJgi8mpssJ8vUSIqsRaFlfde NzafDBO/mC4aXw4QPBIneZ9kKb6AEmJoy0BSC0s0b7rv/H7Dd7LqU0WicsZ1oNrL9FepdSJBJJZL9 No54CShhzc5PlHZLn929qk+02aBERQiEvwLSkxtE08wrv/ujH5J5+CaE0BNdAEuxLJ+4Y9BE/tUhM RZz6+IJLoH084FpFlzJicHkBjosb29+qpmnoL1qyLaOSCnj88DEtEmneqKhWfztwf1lvQW4saAQTn mopHYgvC4FQxooW4ChNkaVvOKXmUM+68Yl4XgxIOwlG/3ucGwTVoa3TH7wYGaGr1AorNvWbULm17P 0k6oZvhg==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=toshino.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o5pbO-003N2J-0V; Mon, 27 Jun 2022 17:20:32 +0300 From: Mikko Perttunen To: Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Dmitry Osipenko Cc: Mikko Perttunen , Robin Murphy , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7/v3 15/22] gpu: host1x: Program virtualization tables Date: Mon, 27 Jun 2022 17:20:01 +0300 Message-Id: <20220627142008.2072474-16-cyndis@kapsi.fi> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627142008.2072474-1-cyndis@kapsi.fi> References: <20220627142008.2072474-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 Program virtualization tables specifying which VMs have access to which Host1x hardware resources. Programming these has become mandatory in Tegra234. For now, since the driver does not operate as a Host1x hypervisor, we basically allow access to everything to everyone. Signed-off-by: Mikko Perttunen --- drivers/gpu/host1x/dev.c | 21 ++++++++++++++++++--- drivers/gpu/host1x/dev.h | 8 ++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 8c6ce8014c09..5a57165ab0f6 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -217,7 +217,7 @@ static const struct of_device_id host1x_of_match[] = { }; MODULE_DEVICE_TABLE(of, host1x_of_match); -static void host1x_setup_sid_table(struct host1x *host) +static void host1x_setup_virtualization_tables(struct host1x *host) { const struct host1x_info *info = host->info; unsigned int i; @@ -231,6 +231,21 @@ static void host1x_setup_sid_table(struct host1x *host) host1x_hypervisor_writel(host, entry->offset, entry->base); host1x_hypervisor_writel(host, entry->limit, entry->base + 4); } + + for (i = 0; i < info->streamid_vm_table.count; i++) { + /* Allow access to all stream IDs to all VMs. */ + host1x_hypervisor_writel(host, 0xff, info->streamid_vm_table.base + 4 * i); + } + + for (i = 0; i < info->classid_vm_table.count; i++) { + /* Allow access to all classes to all VMs. */ + host1x_hypervisor_writel(host, 0xff, info->classid_vm_table.base + 4 * i); + } + + for (i = 0; i < info->mmio_vm_table.count; i++) { + /* Use VM1 (that's us) as originator VMID for engine MMIO accesses. */ + host1x_hypervisor_writel(host, 0x1, info->mmio_vm_table.base + 4 * i); + } } static bool host1x_wants_iommu(struct host1x *host1x) @@ -602,7 +617,7 @@ static int __maybe_unused host1x_runtime_suspend(struct device *dev) return 0; resume_host1x: - host1x_setup_sid_table(host); + host1x_setup_virtualization_tables(host); host1x_syncpt_restore(host); host1x_intr_start(host); @@ -632,7 +647,7 @@ static int __maybe_unused host1x_runtime_resume(struct device *dev) goto disable_clk; } - host1x_setup_sid_table(host); + host1x_setup_virtualization_tables(host); host1x_syncpt_restore(host); host1x_intr_start(host); diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h index 85edcc6e0fc7..920e5548cfbc 100644 --- a/drivers/gpu/host1x/dev.h +++ b/drivers/gpu/host1x/dev.h @@ -90,6 +90,11 @@ struct host1x_sid_entry { unsigned int limit; }; +struct host1x_table_desc { + unsigned int base; + unsigned int count; +}; + struct host1x_info { unsigned int nb_channels; /* host1x: number of channels supported */ unsigned int nb_pts; /* host1x: number of syncpoints supported */ @@ -103,6 +108,9 @@ struct host1x_info { bool has_common; /* has common registers separate from hypervisor */ unsigned int num_sid_entries; const struct host1x_sid_entry *sid_table; + struct host1x_table_desc streamid_vm_table; + struct host1x_table_desc classid_vm_table; + struct host1x_table_desc mmio_vm_table; /* * On T20-T148, the boot chain may setup DC to increment syncpoints * 26/27 on VBLANK. As such we cannot use these syncpoints until -- 2.36.1