linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu
@ 2020-12-30 15:29 Iskren Chernev
  2020-12-30 15:29 ` [PATCH 2/2] drm/msm: Add modparam to allow vram carveout Iskren Chernev
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Iskren Chernev @ 2020-12-30 15:29 UTC (permalink / raw)
  To: Rob Clark
  Cc: Akhil P Oommen, Bjorn Andersson, Brian Masney, Daniel Vetter,
	David Airlie, dri-devel, freedreno, Iskren Chernev,
	Jonathan Marek, Jordan Crouse, linux-arm-msm, linux-kernel,
	Sean Paul, Sharat Masetty, Shawn Guo, Wambui Karuga,
	~postmarketos/upstreaming, Craig Tatlor

From: Craig Tatlor <ctatlor97@gmail.com>

vram.size is needed when binding a gpu without an iommu and is defined
in msm_init_vram(), so run that before binding it.

Signed-off-by: Craig Tatlor <ctatlor97@gmail.com>
---
 drivers/gpu/drm/msm/msm_drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 535a0263ceeb4..108c405e03dd9 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -457,14 +457,14 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
 
 	drm_mode_config_init(ddev);
 
-	/* Bind all our sub-components: */
-	ret = component_bind_all(dev, ddev);
+	ret = msm_init_vram(ddev);
 	if (ret)
 		goto err_destroy_mdss;
 
-	ret = msm_init_vram(ddev);
+	/* Bind all our sub-components: */
+	ret = component_bind_all(dev, ddev);
 	if (ret)
-		goto err_msm_uninit;
+		goto err_destroy_mdss;
 
 	dma_set_max_seg_size(dev, UINT_MAX);
 

base-commit: d7a03a44a5e93f39ece70ec75d25c6088caa0fdb
prerequisite-patch-id: aba6f684932cab35d98457c21e4ff7a5ac75c753
prerequisite-patch-id: 4884d57df1bd197896b69e115d9002d6c26ae2e2
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] drm/msm: Add modparam to allow vram carveout
  2020-12-30 15:29 [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Iskren Chernev
@ 2020-12-30 15:29 ` Iskren Chernev
  2020-12-30 22:23 ` [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Brian Masney
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Iskren Chernev @ 2020-12-30 15:29 UTC (permalink / raw)
  To: Rob Clark
  Cc: Akhil P Oommen, Bjorn Andersson, Brian Masney, Daniel Vetter,
	David Airlie, dri-devel, freedreno, Iskren Chernev,
	Jonathan Marek, Jordan Crouse, linux-arm-msm, linux-kernel,
	Sean Paul, Sharat Masetty, Shawn Guo, Wambui Karuga,
	~postmarketos/upstreaming

Using the GPU with a VRAM Carveout is a security vulnerability.
Nevertheless it is sometimes required, especially when no IOMMU
implementation is available for a certain platform.

Signed-off-by: Iskren Chernev <iskren.chernev@gmail.com>
---
 drivers/gpu/drm/msm/adreno/a2xx_gpu.c      | 6 ++++--
 drivers/gpu/drm/msm/adreno/a3xx_gpu.c      | 6 ++++--
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c      | 6 ++++--
 drivers/gpu/drm/msm/adreno/adreno_device.c | 4 ++++
 drivers/gpu/drm/msm/adreno/adreno_gpu.h    | 1 +
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
index 7e82c41a85f1a..bdc989183c648 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
@@ -534,8 +534,10 @@ struct msm_gpu *a2xx_gpu_init(struct drm_device *dev)
 
 	if (!gpu->aspace) {
 		dev_err(dev->dev, "No memory protection without MMU\n");
-		ret = -ENXIO;
-		goto fail;
+		if (!allow_vram_carveout) {
+			ret = -ENXIO;
+			goto fail;
+		}
 	}
 
 	return gpu;
diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index 93da6683a8661..4534633fe7cdb 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -564,8 +564,10 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
 		 * implement a cmdstream validator.
 		 */
 		DRM_DEV_ERROR(dev->dev, "No memory protection without IOMMU\n");
-		ret = -ENXIO;
-		goto fail;
+		if (!allow_vram_carveout) {
+			ret = -ENXIO;
+			goto fail;
+		}
 	}
 
 	icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem");
diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
index c0be3a0f36b2c..82bebb40234de 100644
--- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
@@ -692,8 +692,10 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
 		 * implement a cmdstream validator.
 		 */
 		DRM_DEV_ERROR(dev->dev, "No memory protection without IOMMU\n");
-		ret = -ENXIO;
-		goto fail;
+		if (!allow_vram_carveout) {
+			ret = -ENXIO;
+			goto fail;
+		}
 	}
 
 	icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem");
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 87c8b033ad1a6..12e75ba360f95 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -18,6 +18,10 @@ bool snapshot_debugbus = false;
 MODULE_PARM_DESC(snapshot_debugbus, "Include debugbus sections in GPU devcoredump (if not fused off)");
 module_param_named(snapshot_debugbus, snapshot_debugbus, bool, 0600);
 
+bool allow_vram_carveout = false;
+MODULE_PARM_DESC(allow_vram_carveout, "Allow using VRAM Carveout, in place of IOMMU");
+module_param_named(allow_vram_carveout, allow_vram_carveout, bool, 0600);
+
 static const struct adreno_info gpulist[] = {
 	{
 		.rev   = ADRENO_REV(2, 0, 0, 0),
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index c3775f79525a7..fe5444a1482ae 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -18,6 +18,7 @@
 #include "adreno_pm4.xml.h"
 
 extern bool snapshot_debugbus;
+extern bool allow_vram_carveout;
 
 enum {
 	ADRENO_FW_PM4 = 0,
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu
  2020-12-30 15:29 [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Iskren Chernev
  2020-12-30 15:29 ` [PATCH 2/2] drm/msm: Add modparam to allow vram carveout Iskren Chernev
@ 2020-12-30 22:23 ` Brian Masney
  2021-01-03  6:09 ` Alexey Minnekhanov
  2021-03-01 19:59 ` patchwork-bot+linux-arm-msm
  3 siblings, 0 replies; 5+ messages in thread
From: Brian Masney @ 2020-12-30 22:23 UTC (permalink / raw)
  To: Iskren Chernev
  Cc: Rob Clark, Akhil P Oommen, Bjorn Andersson, Daniel Vetter,
	David Airlie, dri-devel, freedreno, Jonathan Marek,
	Jordan Crouse, linux-arm-msm, linux-kernel, Sean Paul,
	Sharat Masetty, Shawn Guo, Wambui Karuga,
	~postmarketos/upstreaming, Craig Tatlor

On Wed, Dec 30, 2020 at 05:29:42PM +0200, Iskren Chernev wrote:
> From: Craig Tatlor <ctatlor97@gmail.com>
> 
> vram.size is needed when binding a gpu without an iommu and is defined
> in msm_init_vram(), so run that before binding it.
> 
> Signed-off-by: Craig Tatlor <ctatlor97@gmail.com>

For the series:

Reviewed-by: Brian Masney <masneyb@onstation.org>

Next time, please include a cover letter so that tags added to the cover
letter can be applied to all patches in the series via patchwork.

Brian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu
  2020-12-30 15:29 [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Iskren Chernev
  2020-12-30 15:29 ` [PATCH 2/2] drm/msm: Add modparam to allow vram carveout Iskren Chernev
  2020-12-30 22:23 ` [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Brian Masney
@ 2021-01-03  6:09 ` Alexey Minnekhanov
  2021-03-01 19:59 ` patchwork-bot+linux-arm-msm
  3 siblings, 0 replies; 5+ messages in thread
From: Alexey Minnekhanov @ 2021-01-03  6:09 UTC (permalink / raw)
  To: Iskren Chernev, Rob Clark
  Cc: Akhil P Oommen, Bjorn Andersson, Brian Masney, Daniel Vetter,
	David Airlie, dri-devel, freedreno, Jonathan Marek,
	Jordan Crouse, linux-arm-msm, linux-kernel, Sean Paul,
	Sharat Masetty, Shawn Guo, Wambui Karuga,
	~postmarketos/upstreaming, Craig Tatlor

Tested these patches on Samsung Galaxy S5 along with other patches that 
add panel driver and enable GPU support on this device.

Tested-by: Alexey Minnekhanov <alexeymin@postmarketos.org>

On 12/30/20 6:29 PM, Iskren Chernev wrote:
> From: Craig Tatlor <ctatlor97@gmail.com>
> 
> vram.size is needed when binding a gpu without an iommu and is defined
> in msm_init_vram(), so run that before binding it.
> 
> Signed-off-by: Craig Tatlor <ctatlor97@gmail.com>
> ---
>   drivers/gpu/drm/msm/msm_drv.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu
  2020-12-30 15:29 [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Iskren Chernev
                   ` (2 preceding siblings ...)
  2021-01-03  6:09 ` Alexey Minnekhanov
@ 2021-03-01 19:59 ` patchwork-bot+linux-arm-msm
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-03-01 19:59 UTC (permalink / raw)
  To: Iskren Chernev; +Cc: linux-arm-msm

Hello:

This series was applied to qcom/linux.git (refs/heads/for-next):

On Wed, 30 Dec 2020 17:29:42 +0200 you wrote:
> From: Craig Tatlor <ctatlor97@gmail.com>
> 
> vram.size is needed when binding a gpu without an iommu and is defined
> in msm_init_vram(), so run that before binding it.
> 
> Signed-off-by: Craig Tatlor <ctatlor97@gmail.com>
> 
> [...]

Here is the summary with links:
  - [1/2] drm/msm: Call msm_init_vram before binding the gpu
    https://git.kernel.org/qcom/c/d863f0c7b536
  - [2/2] drm/msm: Add modparam to allow vram carveout
    https://git.kernel.org/qcom/c/3f7759e7b758

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-01 20:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30 15:29 [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Iskren Chernev
2020-12-30 15:29 ` [PATCH 2/2] drm/msm: Add modparam to allow vram carveout Iskren Chernev
2020-12-30 22:23 ` [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Brian Masney
2021-01-03  6:09 ` Alexey Minnekhanov
2021-03-01 19:59 ` patchwork-bot+linux-arm-msm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).