Skip to content

Commit 71fa42f

Browse files
committed
Merge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux into drm-next
- Disable DMA when using SEV encryption - An -RT fix - Code cleanups Signed-off-by: Dave Airlie <[email protected]> From: "Thomas Hellstrom (VMware)" <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 9001b17 + 6b65675 commit 71fa42f

File tree

9 files changed

+14
-148
lines changed

9 files changed

+14
-148
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,8 @@ int vmw_cmdbuf_set_pool_size(struct vmw_cmdbuf_man *man,
12411241
* actually call into the already enabled manager, when
12421242
* binding the MOB.
12431243
*/
1244-
if (!(dev_priv->capabilities & SVGA_CAP_DX))
1244+
if (!(dev_priv->capabilities & SVGA_CAP_DX) ||
1245+
!dev_priv->has_mob)
12451246
return -ENOMEM;
12461247

12471248
ret = ttm_bo_create(&dev_priv->bdev, size, ttm_bo_type_device,

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/dma-mapping.h>
3030
#include <linux/module.h>
3131
#include <linux/pci.h>
32+
#include <linux/mem_encrypt.h>
3233

3334
#include <drm/drm_drv.h>
3435
#include <drm/drm_ioctl.h>
@@ -575,6 +576,10 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
575576
[vmw_dma_map_populate] = "Caching DMA mappings.",
576577
[vmw_dma_map_bind] = "Giving up DMA mappings early."};
577578

579+
/* TTM currently doesn't fully support SEV encryption. */
580+
if (mem_encrypt_active())
581+
return -EINVAL;
582+
578583
if (vmw_force_coherent)
579584
dev_priv->map_mode = vmw_dma_alloc_coherent;
580585
else if (vmw_restrict_iommu)
@@ -682,8 +687,10 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
682687

683688
ret = vmw_dma_select_mode(dev_priv);
684689
if (unlikely(ret != 0)) {
685-
DRM_INFO("Restricting capabilities due to IOMMU setup.\n");
690+
DRM_INFO("Restricting capabilities since DMA not available.\n");
686691
refuse_dma = true;
692+
if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS)
693+
DRM_INFO("Disabling 3D acceleration.\n");
687694
}
688695

689696
dev_priv->vram_size = vmw_read(dev_priv, SVGA_REG_VRAM_SIZE);
@@ -866,7 +873,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
866873
dev_priv->has_gmr = false;
867874
}
868875

869-
if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) {
876+
if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS && !refuse_dma) {
870877
dev_priv->has_mob = true;
871878
if (ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_MOB,
872879
VMW_PL_MOB) != 0) {

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,6 @@ struct vmw_private {
479479
bool assume_16bpp;
480480
bool has_sm4_1;
481481

482-
/*
483-
* VGA registers.
484-
*/
485-
486-
struct vmw_vga_topology_state vga_save[VMWGFX_MAX_DISPLAYS];
487-
uint32_t vga_width;
488-
uint32_t vga_height;
489-
uint32_t vga_bpp;
490-
uint32_t vga_bpl;
491-
uint32_t vga_pitchlock;
492-
493-
uint32_t num_displays;
494-
495482
/*
496483
* Framebuffer info.
497484
*/
@@ -900,7 +887,6 @@ extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes);
900887
extern void vmw_fifo_commit_flush(struct vmw_private *dev_priv, uint32_t bytes);
901888
extern int vmw_fifo_send_fence(struct vmw_private *dev_priv,
902889
uint32_t *seqno);
903-
extern void vmw_fifo_ping_host_locked(struct vmw_private *, uint32_t reason);
904890
extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason);
905891
extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv);
906892
extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv);
@@ -947,7 +933,6 @@ extern struct ttm_placement vmw_mob_placement;
947933
extern struct ttm_placement vmw_mob_ne_placement;
948934
extern struct ttm_placement vmw_nonfixed_placement;
949935
extern struct ttm_bo_driver vmw_bo_driver;
950-
extern int vmw_dma_quiescent(struct drm_device *dev);
951936
extern int vmw_bo_map_dma(struct ttm_buffer_object *bo);
952937
extern void vmw_bo_unmap_dma(struct ttm_buffer_object *bo);
953938
extern const struct vmw_sg_table *
@@ -1085,8 +1070,6 @@ int vmw_fb_on(struct vmw_private *vmw_priv);
10851070

10861071
int vmw_kms_init(struct vmw_private *dev_priv);
10871072
int vmw_kms_close(struct vmw_private *dev_priv);
1088-
int vmw_kms_save_vga(struct vmw_private *vmw_priv);
1089-
int vmw_kms_restore_vga(struct vmw_private *vmw_priv);
10901073
int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
10911074
struct drm_file *file_priv);
10921075
void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv);
@@ -1139,7 +1122,6 @@ int vmw_overlay_init(struct vmw_private *dev_priv);
11391122
int vmw_overlay_close(struct vmw_private *dev_priv);
11401123
int vmw_overlay_ioctl(struct drm_device *dev, void *data,
11411124
struct drm_file *file_priv);
1142-
int vmw_overlay_stop_all(struct vmw_private *dev_priv);
11431125
int vmw_overlay_resume_all(struct vmw_private *dev_priv);
11441126
int vmw_overlay_pause_all(struct vmw_private *dev_priv);
11451127
int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out);
@@ -1186,10 +1168,6 @@ extern void vmw_otables_takedown(struct vmw_private *dev_priv);
11861168

11871169
extern const struct vmw_user_resource_conv *user_context_converter;
11881170

1189-
extern int vmw_context_check(struct vmw_private *dev_priv,
1190-
struct ttm_object_file *tfile,
1191-
int id,
1192-
struct vmw_resource **p_res);
11931171
extern int vmw_context_define_ioctl(struct drm_device *dev, void *data,
11941172
struct drm_file *file_priv);
11951173
extern int vmw_extended_context_define_ioctl(struct drm_device *dev, void *data,
@@ -1219,7 +1197,6 @@ vmw_context_get_dx_query_mob(struct vmw_resource *ctx_res);
12191197

12201198
extern const struct vmw_user_resource_conv *user_surface_converter;
12211199

1222-
extern void vmw_surface_res_free(struct vmw_resource *res);
12231200
extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
12241201
struct drm_file *file_priv);
12251202
extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
@@ -1230,11 +1207,6 @@ extern int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
12301207
struct drm_file *file_priv);
12311208
extern int vmw_gb_surface_reference_ioctl(struct drm_device *dev, void *data,
12321209
struct drm_file *file_priv);
1233-
extern int vmw_surface_check(struct vmw_private *dev_priv,
1234-
struct ttm_object_file *tfile,
1235-
uint32_t handle, int *id);
1236-
extern int vmw_surface_validate(struct vmw_private *dev_priv,
1237-
struct vmw_surface *srf);
12381210
int vmw_surface_gb_priv_define(struct drm_device *dev,
12391211
uint32_t user_accounting_size,
12401212
SVGA3dSurfaceAllFlags svga3d_flags,

drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason)
169169
{
170170
u32 *fifo_mem = dev_priv->mmio_virt;
171171

172-
preempt_disable();
173172
if (cmpxchg(fifo_mem + SVGA_FIFO_BUSY, 0, 1) == 0)
174173
vmw_write(dev_priv, SVGA_REG_SYNC, reason);
175-
preempt_enable();
176174
}
177175

178176
void vmw_fifo_release(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,87 +1897,6 @@ int vmw_kms_write_svga(struct vmw_private *vmw_priv,
18971897
return 0;
18981898
}
18991899

1900-
int vmw_kms_save_vga(struct vmw_private *vmw_priv)
1901-
{
1902-
struct vmw_vga_topology_state *save;
1903-
uint32_t i;
1904-
1905-
vmw_priv->vga_width = vmw_read(vmw_priv, SVGA_REG_WIDTH);
1906-
vmw_priv->vga_height = vmw_read(vmw_priv, SVGA_REG_HEIGHT);
1907-
vmw_priv->vga_bpp = vmw_read(vmw_priv, SVGA_REG_BITS_PER_PIXEL);
1908-
if (vmw_priv->capabilities & SVGA_CAP_PITCHLOCK)
1909-
vmw_priv->vga_pitchlock =
1910-
vmw_read(vmw_priv, SVGA_REG_PITCHLOCK);
1911-
else if (vmw_fifo_have_pitchlock(vmw_priv))
1912-
vmw_priv->vga_pitchlock = vmw_mmio_read(vmw_priv->mmio_virt +
1913-
SVGA_FIFO_PITCHLOCK);
1914-
1915-
if (!(vmw_priv->capabilities & SVGA_CAP_DISPLAY_TOPOLOGY))
1916-
return 0;
1917-
1918-
vmw_priv->num_displays = vmw_read(vmw_priv,
1919-
SVGA_REG_NUM_GUEST_DISPLAYS);
1920-
1921-
if (vmw_priv->num_displays == 0)
1922-
vmw_priv->num_displays = 1;
1923-
1924-
for (i = 0; i < vmw_priv->num_displays; ++i) {
1925-
save = &vmw_priv->vga_save[i];
1926-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, i);
1927-
save->primary = vmw_read(vmw_priv, SVGA_REG_DISPLAY_IS_PRIMARY);
1928-
save->pos_x = vmw_read(vmw_priv, SVGA_REG_DISPLAY_POSITION_X);
1929-
save->pos_y = vmw_read(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y);
1930-
save->width = vmw_read(vmw_priv, SVGA_REG_DISPLAY_WIDTH);
1931-
save->height = vmw_read(vmw_priv, SVGA_REG_DISPLAY_HEIGHT);
1932-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
1933-
if (i == 0 && vmw_priv->num_displays == 1 &&
1934-
save->width == 0 && save->height == 0) {
1935-
1936-
/*
1937-
* It should be fairly safe to assume that these
1938-
* values are uninitialized.
1939-
*/
1940-
1941-
save->width = vmw_priv->vga_width - save->pos_x;
1942-
save->height = vmw_priv->vga_height - save->pos_y;
1943-
}
1944-
}
1945-
1946-
return 0;
1947-
}
1948-
1949-
int vmw_kms_restore_vga(struct vmw_private *vmw_priv)
1950-
{
1951-
struct vmw_vga_topology_state *save;
1952-
uint32_t i;
1953-
1954-
vmw_write(vmw_priv, SVGA_REG_WIDTH, vmw_priv->vga_width);
1955-
vmw_write(vmw_priv, SVGA_REG_HEIGHT, vmw_priv->vga_height);
1956-
vmw_write(vmw_priv, SVGA_REG_BITS_PER_PIXEL, vmw_priv->vga_bpp);
1957-
if (vmw_priv->capabilities & SVGA_CAP_PITCHLOCK)
1958-
vmw_write(vmw_priv, SVGA_REG_PITCHLOCK,
1959-
vmw_priv->vga_pitchlock);
1960-
else if (vmw_fifo_have_pitchlock(vmw_priv))
1961-
vmw_mmio_write(vmw_priv->vga_pitchlock,
1962-
vmw_priv->mmio_virt + SVGA_FIFO_PITCHLOCK);
1963-
1964-
if (!(vmw_priv->capabilities & SVGA_CAP_DISPLAY_TOPOLOGY))
1965-
return 0;
1966-
1967-
for (i = 0; i < vmw_priv->num_displays; ++i) {
1968-
save = &vmw_priv->vga_save[i];
1969-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, i);
1970-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_IS_PRIMARY, save->primary);
1971-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_X, save->pos_x);
1972-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, save->pos_y);
1973-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, save->width);
1974-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, save->height);
1975-
vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
1976-
}
1977-
1978-
return 0;
1979-
}
1980-
19811900
bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
19821901
uint32_t pitch,
19831902
uint32_t height)

drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -353,37 +353,6 @@ static int vmw_overlay_update_stream(struct vmw_private *dev_priv,
353353
return 0;
354354
}
355355

356-
/**
357-
* Stop all streams.
358-
*
359-
* Used by the fb code when starting.
360-
*
361-
* Takes the overlay lock.
362-
*/
363-
int vmw_overlay_stop_all(struct vmw_private *dev_priv)
364-
{
365-
struct vmw_overlay *overlay = dev_priv->overlay_priv;
366-
int i, ret;
367-
368-
if (!overlay)
369-
return 0;
370-
371-
mutex_lock(&overlay->mutex);
372-
373-
for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
374-
struct vmw_stream *stream = &overlay->stream[i];
375-
if (!stream->buf)
376-
continue;
377-
378-
ret = vmw_overlay_stop(dev_priv, i, false, false);
379-
WARN_ON(ret != 0);
380-
}
381-
382-
mutex_unlock(&overlay->mutex);
383-
384-
return 0;
385-
}
386-
387356
/**
388357
* Try to resume all paused streams.
389358
*

drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct vmw_bo_dirty {
6969
unsigned int ref_count;
7070
unsigned long bitmap_size;
7171
size_t size;
72-
unsigned long bitmap[0];
72+
unsigned long bitmap[];
7373
};
7474

7575
/**

drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,7 @@ int vmw_kms_stdu_init_display(struct vmw_private *dev_priv)
18881888

18891889

18901890
/* Do nothing if Screen Target support is turned off */
1891-
if (!VMWGFX_ENABLE_SCREEN_TARGET_OTABLE)
1891+
if (!VMWGFX_ENABLE_SCREEN_TARGET_OTABLE || !dev_priv->has_mob)
18921892
return -ENOSYS;
18931893

18941894
if (!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS))

drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct vmw_surface_dirty {
7979
struct svga3dsurface_cache cache;
8080
size_t size;
8181
u32 num_subres;
82-
SVGA3dBox boxes[0];
82+
SVGA3dBox boxes[];
8383
};
8484

8585
static void vmw_user_surface_free(struct vmw_resource *res);

0 commit comments

Comments
 (0)