diff mbox series

drm/vmwgfx: Enable DMA mappings with SEV

Message ID 20240408022802.358641-1-zack.rusin@broadcom.com (mailing list archive)
State New, archived
Headers show
Series drm/vmwgfx: Enable DMA mappings with SEV | expand

Commit Message

Zack Rusin April 8, 2024, 2:28 a.m. UTC
Enable DMA mappings in vmwgfx after TTM has been fixed in commit
3bf3710e3718 ("drm/ttm: Add a generic TTM memcpy move for page-based iomem")

This enables full guest-backed memory support and in particular allows
usage of screen targets as the presentation mechanism.

Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reported-by: Ye Li <ye.li@broadcom.com>
Tested-by: Ye Li <ye.li@broadcom.com>
Fixes: 3b0d6458c705 ("drm/vmwgfx: Refuse DMA operation when SEV encryption is active")
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.6+
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Martin Krastev April 9, 2024, 11:56 a.m. UTC | #1
On Mon, Apr 8, 2024 at 5:28 AM Zack Rusin <zack.rusin@broadcom.com> wrote:
>
> Enable DMA mappings in vmwgfx after TTM has been fixed in commit
> 3bf3710e3718 ("drm/ttm: Add a generic TTM memcpy move for page-based iomem")
>
> This enables full guest-backed memory support and in particular allows
> usage of screen targets as the presentation mechanism.
>
> Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
> Reported-by: Ye Li <ye.li@broadcom.com>
> Tested-by: Ye Li <ye.li@broadcom.com>
> Fixes: 3b0d6458c705 ("drm/vmwgfx: Refuse DMA operation when SEV encryption is active")
> Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.6+
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 41ad13e45554..bdad93864b98 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -667,11 +667,12 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
>                 [vmw_dma_map_populate] = "Caching DMA mappings.",
>                 [vmw_dma_map_bind] = "Giving up DMA mappings early."};
>
> -       /* TTM currently doesn't fully support SEV encryption. */
> -       if (cc_platform_has(CC_ATTR_MEM_ENCRYPT))
> -               return -EINVAL;
> -
> -       if (vmw_force_coherent)
> +       /*
> +        * When running with SEV we always want dma mappings, because
> +        * otherwise ttm tt pool pages will bounce through swiotlb running
> +        * out of available space.
> +        */
> +       if (vmw_force_coherent || cc_platform_has(CC_ATTR_MEM_ENCRYPT))
>                 dev_priv->map_mode = vmw_dma_alloc_coherent;
>         else if (vmw_restrict_iommu)
>                 dev_priv->map_mode = vmw_dma_map_bind;
> --
> 2.40.1


LGTM!

Reviewed-by: Martin Krastev <martin.krastev@broadcom.com>

Regards,
Martin
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 41ad13e45554..bdad93864b98 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -667,11 +667,12 @@  static int vmw_dma_select_mode(struct vmw_private *dev_priv)
 		[vmw_dma_map_populate] = "Caching DMA mappings.",
 		[vmw_dma_map_bind] = "Giving up DMA mappings early."};
 
-	/* TTM currently doesn't fully support SEV encryption. */
-	if (cc_platform_has(CC_ATTR_MEM_ENCRYPT))
-		return -EINVAL;
-
-	if (vmw_force_coherent)
+	/*
+	 * When running with SEV we always want dma mappings, because
+	 * otherwise ttm tt pool pages will bounce through swiotlb running
+	 * out of available space.
+	 */
+	if (vmw_force_coherent || cc_platform_has(CC_ATTR_MEM_ENCRYPT))
 		dev_priv->map_mode = vmw_dma_alloc_coherent;
 	else if (vmw_restrict_iommu)
 		dev_priv->map_mode = vmw_dma_map_bind;