From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37778C433F5 for ; Mon, 21 Feb 2022 17:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239320AbiBUR2L (ORCPT ); Mon, 21 Feb 2022 12:28:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236985AbiBUR2I (ORCPT ); Mon, 21 Feb 2022 12:28:08 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C624419C02; Mon, 21 Feb 2022 09:27:44 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F5DB1063; Mon, 21 Feb 2022 09:27:44 -0800 (PST) Received: from [10.57.40.147] (unknown [10.57.40.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D1663F70D; Mon, 21 Feb 2022 09:27:42 -0800 (PST) Message-ID: <71e94ac3-20fc-6f41-270f-fe246740e7e0@arm.com> Date: Mon, 21 Feb 2022 17:27:30 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset Content-Language: en-GB To: Mikko Perttunen , thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20220218113952.3077606-1-mperttunen@nvidia.com> <20220218113952.3077606-9-mperttunen@nvidia.com> From: Robin Murphy In-Reply-To: <20220218113952.3077606-9-mperttunen@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: > Implement the get_streamid_offset required for supporting context > isolation. Since old firmware cannot support context isolation > without hacks that we don't want to implement, check the firmware > binary to see if context isolation should be enabled. > > Signed-off-by: Mikko Perttunen > --- > drivers/gpu/drm/tegra/vic.c | 38 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c > index 1e342fa3d27b..2863ee5e0e67 100644 > --- a/drivers/gpu/drm/tegra/vic.c > +++ b/drivers/gpu/drm/tegra/vic.c > @@ -38,6 +38,8 @@ struct vic { > struct clk *clk; > struct reset_control *rst; > > + bool can_use_context; > + > /* Platform configuration */ > const struct vic_config *config; > }; > @@ -229,6 +231,7 @@ static int vic_load_firmware(struct vic *vic) > { > struct host1x_client *client = &vic->client.base; > struct tegra_drm *tegra = vic->client.drm; > + u32 fce_bin_data_offset; > dma_addr_t iova; > size_t size; > void *virt; > @@ -277,6 +280,25 @@ static int vic_load_firmware(struct vic *vic) > vic->falcon.firmware.phys = phys; > } > > + /* > + * Check if firmware is new enough to not require mapping firmware > + * to data buffer domains. > + */ > + fce_bin_data_offset = *(u32 *)(virt + VIC_UCODE_FCE_DATA_OFFSET); > + > + if (!vic->config->supports_sid) { > + vic->can_use_context = false; > + } else if (fce_bin_data_offset != 0x0 && fce_bin_data_offset != 0xa5a5a5a5) { > + /* > + * Firmware will access FCE through STREAMID0, so context > + * isolation cannot be used. > + */ > + vic->can_use_context = false; > + dev_warn_once(vic->dev, "context isolation disabled due to old firmware\n"); > + } else { > + vic->can_use_context = true; > + } > + > return 0; > > cleanup: > @@ -358,10 +380,26 @@ static void vic_close_channel(struct tegra_drm_context *context) > host1x_channel_put(context->channel); > } > > +static int vic_get_streamid_offset(struct tegra_drm_client *client) > +{ > + struct vic *vic = to_vic(client); > + int err; > + > + err = vic_load_firmware(vic); > + if (err < 0) > + return err; > + > + if (vic->can_use_context) > + return 0x30; > + else > + return -ENOTSUPP; > +} > + > static const struct tegra_drm_client_ops vic_ops = { > .open_channel = vic_open_channel, > .close_channel = vic_close_channel, > .submit = tegra_drm_submit, > + .get_streamid_offset = vic_get_streamid_offset, The patch order seems off here, since the .get_streamid_offset member isn't defined yet. Robin. > }; > > #define NVIDIA_TEGRA_124_VIC_FIRMWARE "nvidia/tegra124/vic03_ucode.bin" From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46006C433EF for ; Mon, 21 Feb 2022 17:27:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C6AD74052F; Mon, 21 Feb 2022 17:27:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r-QMrbkTBgfl; Mon, 21 Feb 2022 17:27:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5D3B5400A8; Mon, 21 Feb 2022 17:27:47 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3FBECC001A; Mon, 21 Feb 2022 17:27:47 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4289BC0011 for ; Mon, 21 Feb 2022 17:27:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2A166408AE for ; Mon, 21 Feb 2022 17:27:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZawJPPS9L2T8 for ; Mon, 21 Feb 2022 17:27:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp4.osuosl.org (Postfix) with ESMTP id 67743402D7 for ; Mon, 21 Feb 2022 17:27:45 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F5DB1063; Mon, 21 Feb 2022 09:27:44 -0800 (PST) Received: from [10.57.40.147] (unknown [10.57.40.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D1663F70D; Mon, 21 Feb 2022 09:27:42 -0800 (PST) Message-ID: <71e94ac3-20fc-6f41-270f-fe246740e7e0@arm.com> Date: Mon, 21 Feb 2022 17:27:30 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset Content-Language: en-GB To: Mikko Perttunen , thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robh+dt@kernel.org References: <20220218113952.3077606-1-mperttunen@nvidia.com> <20220218113952.3077606-9-mperttunen@nvidia.com> From: Robin Murphy In-Reply-To: <20220218113952.3077606-9-mperttunen@nvidia.com> Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: > Implement the get_streamid_offset required for supporting context > isolation. Since old firmware cannot support context isolation > without hacks that we don't want to implement, check the firmware > binary to see if context isolation should be enabled. > > Signed-off-by: Mikko Perttunen > --- > drivers/gpu/drm/tegra/vic.c | 38 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c > index 1e342fa3d27b..2863ee5e0e67 100644 > --- a/drivers/gpu/drm/tegra/vic.c > +++ b/drivers/gpu/drm/tegra/vic.c > @@ -38,6 +38,8 @@ struct vic { > struct clk *clk; > struct reset_control *rst; > > + bool can_use_context; > + > /* Platform configuration */ > const struct vic_config *config; > }; > @@ -229,6 +231,7 @@ static int vic_load_firmware(struct vic *vic) > { > struct host1x_client *client = &vic->client.base; > struct tegra_drm *tegra = vic->client.drm; > + u32 fce_bin_data_offset; > dma_addr_t iova; > size_t size; > void *virt; > @@ -277,6 +280,25 @@ static int vic_load_firmware(struct vic *vic) > vic->falcon.firmware.phys = phys; > } > > + /* > + * Check if firmware is new enough to not require mapping firmware > + * to data buffer domains. > + */ > + fce_bin_data_offset = *(u32 *)(virt + VIC_UCODE_FCE_DATA_OFFSET); > + > + if (!vic->config->supports_sid) { > + vic->can_use_context = false; > + } else if (fce_bin_data_offset != 0x0 && fce_bin_data_offset != 0xa5a5a5a5) { > + /* > + * Firmware will access FCE through STREAMID0, so context > + * isolation cannot be used. > + */ > + vic->can_use_context = false; > + dev_warn_once(vic->dev, "context isolation disabled due to old firmware\n"); > + } else { > + vic->can_use_context = true; > + } > + > return 0; > > cleanup: > @@ -358,10 +380,26 @@ static void vic_close_channel(struct tegra_drm_context *context) > host1x_channel_put(context->channel); > } > > +static int vic_get_streamid_offset(struct tegra_drm_client *client) > +{ > + struct vic *vic = to_vic(client); > + int err; > + > + err = vic_load_firmware(vic); > + if (err < 0) > + return err; > + > + if (vic->can_use_context) > + return 0x30; > + else > + return -ENOTSUPP; > +} > + > static const struct tegra_drm_client_ops vic_ops = { > .open_channel = vic_open_channel, > .close_channel = vic_close_channel, > .submit = tegra_drm_submit, > + .get_streamid_offset = vic_get_streamid_offset, The patch order seems off here, since the .get_streamid_offset member isn't defined yet. Robin. > }; > > #define NVIDIA_TEGRA_124_VIC_FIRMWARE "nvidia/tegra124/vic03_ucode.bin" _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1111EC433F5 for ; Mon, 21 Feb 2022 17:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hIPHOGeINaE9wzPKnFF2HJM9Xrhz+iuNrTiJyZdcG5U=; b=tLUsnLqPYenq/Z 2ZFrGDJz6RUQhTGeWN83NthkQ5LjJ+cfmd5k7bxPwXRBO2tu4AJJZqPt3iAJnOGKVO8qmA9zzQ+q+ 0v/Fij+yj+aImKy4y48BlwLKrnPUvIIFH6FL6RJCzoBwjITmXphWbS+sjpLUCJ8LTBXNHl8+VWNql KngOVYn0ESNBPw8MFh5JYyhvJZkFFE0NfqvzL2ADlHBSzGa+TWiLa4agGGJHofpcVpZokGpe+/bGd ZE+Hqyo+8sBaBsMXHgA3lxv/nkRzqxki3w3/BTIoQbxwV3EK2Hmekl2SmxbxIrcTh8YQBIzbiDP1W 8zcVi9R2m6koY20TRWcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMCTV-006mNa-Ua; Mon, 21 Feb 2022 17:27:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMCTR-006mMP-Tw for linux-arm-kernel@lists.infradead.org; Mon, 21 Feb 2022 17:27:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F5DB1063; Mon, 21 Feb 2022 09:27:44 -0800 (PST) Received: from [10.57.40.147] (unknown [10.57.40.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D1663F70D; Mon, 21 Feb 2022 09:27:42 -0800 (PST) Message-ID: <71e94ac3-20fc-6f41-270f-fe246740e7e0@arm.com> Date: Mon, 21 Feb 2022 17:27:30 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset Content-Language: en-GB To: Mikko Perttunen , thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20220218113952.3077606-1-mperttunen@nvidia.com> <20220218113952.3077606-9-mperttunen@nvidia.com> From: Robin Murphy In-Reply-To: <20220218113952.3077606-9-mperttunen@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220221_092746_091039_4F6706A1 X-CRM114-Status: GOOD ( 21.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022-02-18 11:39, Mikko Perttunen via iommu wrote: > Implement the get_streamid_offset required for supporting context > isolation. Since old firmware cannot support context isolation > without hacks that we don't want to implement, check the firmware > binary to see if context isolation should be enabled. > > Signed-off-by: Mikko Perttunen > --- > drivers/gpu/drm/tegra/vic.c | 38 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c > index 1e342fa3d27b..2863ee5e0e67 100644 > --- a/drivers/gpu/drm/tegra/vic.c > +++ b/drivers/gpu/drm/tegra/vic.c > @@ -38,6 +38,8 @@ struct vic { > struct clk *clk; > struct reset_control *rst; > > + bool can_use_context; > + > /* Platform configuration */ > const struct vic_config *config; > }; > @@ -229,6 +231,7 @@ static int vic_load_firmware(struct vic *vic) > { > struct host1x_client *client = &vic->client.base; > struct tegra_drm *tegra = vic->client.drm; > + u32 fce_bin_data_offset; > dma_addr_t iova; > size_t size; > void *virt; > @@ -277,6 +280,25 @@ static int vic_load_firmware(struct vic *vic) > vic->falcon.firmware.phys = phys; > } > > + /* > + * Check if firmware is new enough to not require mapping firmware > + * to data buffer domains. > + */ > + fce_bin_data_offset = *(u32 *)(virt + VIC_UCODE_FCE_DATA_OFFSET); > + > + if (!vic->config->supports_sid) { > + vic->can_use_context = false; > + } else if (fce_bin_data_offset != 0x0 && fce_bin_data_offset != 0xa5a5a5a5) { > + /* > + * Firmware will access FCE through STREAMID0, so context > + * isolation cannot be used. > + */ > + vic->can_use_context = false; > + dev_warn_once(vic->dev, "context isolation disabled due to old firmware\n"); > + } else { > + vic->can_use_context = true; > + } > + > return 0; > > cleanup: > @@ -358,10 +380,26 @@ static void vic_close_channel(struct tegra_drm_context *context) > host1x_channel_put(context->channel); > } > > +static int vic_get_streamid_offset(struct tegra_drm_client *client) > +{ > + struct vic *vic = to_vic(client); > + int err; > + > + err = vic_load_firmware(vic); > + if (err < 0) > + return err; > + > + if (vic->can_use_context) > + return 0x30; > + else > + return -ENOTSUPP; > +} > + > static const struct tegra_drm_client_ops vic_ops = { > .open_channel = vic_open_channel, > .close_channel = vic_close_channel, > .submit = tegra_drm_submit, > + .get_streamid_offset = vic_get_streamid_offset, The patch order seems off here, since the .get_streamid_offset member isn't defined yet. Robin. > }; > > #define NVIDIA_TEGRA_124_VIC_FIRMWARE "nvidia/tegra124/vic03_ucode.bin" _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel