Commit 418a95bc authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux

Pull drm fixes from Dave Airlie:
 "Since we are getting to the pointy end, one i915 black screen on some
  machines, and one vmwgfx stop userspace ability to nuke the VM,

  There might be one or two ati or nouveau fixes trickle in before
  final, but I think this should pretty much be it"

* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
  drm/vmwgfx: Split GMR2_REMAP commands if they are to large
  drm/i915: ivb: fix edp voltage swing reg val
parents 155e3a35 6e4dcff3
...@@ -4440,7 +4440,7 @@ ...@@ -4440,7 +4440,7 @@
#define EDP_LINK_TRAIN_600MV_0DB_IVB (0x30 <<22) #define EDP_LINK_TRAIN_600MV_0DB_IVB (0x30 <<22)
#define EDP_LINK_TRAIN_600MV_3_5DB_IVB (0x36 <<22) #define EDP_LINK_TRAIN_600MV_3_5DB_IVB (0x36 <<22)
#define EDP_LINK_TRAIN_800MV_0DB_IVB (0x38 <<22) #define EDP_LINK_TRAIN_800MV_0DB_IVB (0x38 <<22)
#define EDP_LINK_TRAIN_800MV_3_5DB_IVB (0x33 <<22) #define EDP_LINK_TRAIN_800MV_3_5DB_IVB (0x3e <<22)
/* legacy values */ /* legacy values */
#define EDP_LINK_TRAIN_500MV_0DB_IVB (0x00 <<22) #define EDP_LINK_TRAIN_500MV_0DB_IVB (0x00 <<22)
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/ttm/ttm_bo_driver.h> #include <drm/ttm/ttm_bo_driver.h>
#define VMW_PPN_SIZE sizeof(unsigned long) #define VMW_PPN_SIZE (sizeof(unsigned long))
/* A future safe maximum remap size. */
#define VMW_PPN_PER_REMAP ((31 * 1024) / VMW_PPN_SIZE)
static int vmw_gmr2_bind(struct vmw_private *dev_priv, static int vmw_gmr2_bind(struct vmw_private *dev_priv,
struct page *pages[], struct page *pages[],
...@@ -38,34 +40,46 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv, ...@@ -38,34 +40,46 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv,
{ {
SVGAFifoCmdDefineGMR2 define_cmd; SVGAFifoCmdDefineGMR2 define_cmd;
SVGAFifoCmdRemapGMR2 remap_cmd; SVGAFifoCmdRemapGMR2 remap_cmd;
uint32_t define_size = sizeof(define_cmd) + 4;
uint32_t remap_size = VMW_PPN_SIZE * num_pages + sizeof(remap_cmd) + 4;
uint32_t *cmd; uint32_t *cmd;
uint32_t *cmd_orig; uint32_t *cmd_orig;
uint32_t define_size = sizeof(define_cmd) + sizeof(*cmd);
uint32_t remap_num = num_pages / VMW_PPN_PER_REMAP + ((num_pages % VMW_PPN_PER_REMAP) > 0);
uint32_t remap_size = VMW_PPN_SIZE * num_pages + (sizeof(remap_cmd) + sizeof(*cmd)) * remap_num;
uint32_t remap_pos = 0;
uint32_t cmd_size = define_size + remap_size;
uint32_t i; uint32_t i;
cmd_orig = cmd = vmw_fifo_reserve(dev_priv, define_size + remap_size); cmd_orig = cmd = vmw_fifo_reserve(dev_priv, cmd_size);
if (unlikely(cmd == NULL)) if (unlikely(cmd == NULL))
return -ENOMEM; return -ENOMEM;
define_cmd.gmrId = gmr_id; define_cmd.gmrId = gmr_id;
define_cmd.numPages = num_pages; define_cmd.numPages = num_pages;
*cmd++ = SVGA_CMD_DEFINE_GMR2;
memcpy(cmd, &define_cmd, sizeof(define_cmd));
cmd += sizeof(define_cmd) / sizeof(*cmd);
/*
* Need to split the command if there are too many
* pages that goes into the gmr.
*/
remap_cmd.gmrId = gmr_id; remap_cmd.gmrId = gmr_id;
remap_cmd.flags = (VMW_PPN_SIZE > sizeof(*cmd)) ? remap_cmd.flags = (VMW_PPN_SIZE > sizeof(*cmd)) ?
SVGA_REMAP_GMR2_PPN64 : SVGA_REMAP_GMR2_PPN32; SVGA_REMAP_GMR2_PPN64 : SVGA_REMAP_GMR2_PPN32;
remap_cmd.offsetPages = 0;
remap_cmd.numPages = num_pages;
*cmd++ = SVGA_CMD_DEFINE_GMR2; while (num_pages > 0) {
memcpy(cmd, &define_cmd, sizeof(define_cmd)); unsigned long nr = min(num_pages, (unsigned long)VMW_PPN_PER_REMAP);
cmd += sizeof(define_cmd) / sizeof(uint32);
remap_cmd.offsetPages = remap_pos;
remap_cmd.numPages = nr;
*cmd++ = SVGA_CMD_REMAP_GMR2; *cmd++ = SVGA_CMD_REMAP_GMR2;
memcpy(cmd, &remap_cmd, sizeof(remap_cmd)); memcpy(cmd, &remap_cmd, sizeof(remap_cmd));
cmd += sizeof(remap_cmd) / sizeof(uint32); cmd += sizeof(remap_cmd) / sizeof(*cmd);
for (i = 0; i < num_pages; ++i) { for (i = 0; i < nr; ++i) {
if (VMW_PPN_SIZE <= 4) if (VMW_PPN_SIZE <= 4)
*cmd = page_to_pfn(*pages++); *cmd = page_to_pfn(*pages++);
else else
...@@ -74,7 +88,13 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv, ...@@ -74,7 +88,13 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv,
cmd += VMW_PPN_SIZE / sizeof(*cmd); cmd += VMW_PPN_SIZE / sizeof(*cmd);
} }
vmw_fifo_commit(dev_priv, define_size + remap_size); num_pages -= nr;
remap_pos += nr;
}
BUG_ON(cmd != cmd_orig + cmd_size / sizeof(*cmd));
vmw_fifo_commit(dev_priv, cmd_size);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment