Skip to contentSkip to conversation

drm/vmwgfx: Request SVGA version 2

PATCH In review Jakob Bornecrantz 2 participants 4 messages Jan 28, 2010 – Jan 29, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/vmwgfx: Request SVGA version 2

From: Peter Hanzel <[email protected]>

This fixes the driver not loading on older versions of VMware.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +8 -0
index f47ff2c..8e68333 100644
@@ -209,6 +209,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 {
 	struct vmw_private *dev_priv;
 	int ret;
+ 	long svga_id;
 
 	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
 	if (unlikely(dev_priv == NULL)) {
@@ -239,6 +240,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 	dev_priv->mmio_start = pci_resource_start(dev->pdev, 2);
 
 	mutex_lock(&dev_priv->hw_mutex);
+
+	vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
+	svga_id = vmw_read(dev_priv, SVGA_REG_ID);
+	if (svga_id == SVGA_ID_2) {
+		DRM_INFO("We have SVGA ID 2\n");
+	}
+
 	dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
 
 	if (dev_priv->capabilities & SVGA_CAP_GMR) {
Signature · 10 lines
1.6.0.4


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--
#1 lore raw

PATCH 2/2 drm/vmwgfx: Don't send bad flags to the host

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |    2 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c      |   10 ++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c |   16 +++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +2 -0
index 59acc51..135be96 100644
@@ -96,6 +96,8 @@ struct vmw_surface {
 	struct drm_vmw_size *sizes;
 	uint32_t num_sizes;
 
+	bool scanout;
+
 	/* TODO so far just a extra pointer */
 	struct vmw_cursor_snooper snooper;
 };
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +10 -0
index 686692d..eeba6d1 100644
@@ -707,6 +707,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
 	if (ret)
 		goto try_dmabuf;
 
+	if (!surface->scanout)
+		goto err_not_scanout;
+
 	ret = vmw_kms_new_framebuffer_surface(dev_priv, surface, &vfb,
 					      mode_cmd->width, mode_cmd->height);
 
@@ -740,6 +743,13 @@ try_dmabuf:
 	}
 
 	return &vfb->base;
+
+err_not_scanout:
+	DRM_ERROR("surface not marked as scanout\n");
+	/* vmw_user_surface_lookup takes one ref */
+	vmw_surface_unreference(&surface);
+
+	return NULL;
 }
 
 static int vmw_kms_fb_changed(struct drm_device *dev)
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +15 -1
index e01db12..c7efbd4 100644
@@ -35,6 +35,11 @@
 #define VMW_RES_SURFACE ttm_driver_type1
 #define VMW_RES_STREAM ttm_driver_type2
 
+/* XXX: This isn't a real hardware flag, but just a hack for kernel to
+ * know about primary surfaces. Find a better way to accomplish this.
+ */
+#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
+
 struct vmw_user_context {
 	struct ttm_base_object base;
 	struct vmw_resource res;
@@ -599,8 +604,17 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
 	if (unlikely(ret != 0))
 		goto out_err1;
 
+	if (srf->flags & SVGA3D_SURFACE_HINT_SCANOUT) {
+		/* we should not send this flag down to hardware since
+		 * its not a official one
+		 */
+		srf->flags &= ~SVGA3D_SURFACE_HINT_SCANOUT;
+		srf->scanout = true;
+	} else {
+		srf->scanout = false;
+	}
 
-	if (srf->flags & (1 << 9) &&
+	if (srf->scanout &&
 	    srf->num_sizes == 1 &&
 	    srf->sizes[0].width == 64 &&
 	    srf->sizes[0].height == 64 &&
Signature · 10 lines
1.6.0.4


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--
#2 lore raw
In reply to Jakob Bornecrantz
Quoted 15 lines · Jakob Bornecrantz

From: Peter Hanzel <[email protected]>

This fixes the driver not loading on older versions of VMware.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -0
index f47ff2c..8e68333 100644

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) · line 212

Quoted 4 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -0
@@ -209,6 +209,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 {
 	struct vmw_private *dev_priv;
 	int ret;
+ 	long svga_id;

This should be uint32_t rather than long.

Quoted 4 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -0
@@ -239,6 +240,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 	dev_priv->mmio_start = pci_resource_start(dev->pdev, 2);
 
 	mutex_lock(&dev_priv->hw_mutex);

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) · line 252

Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -0
+
+	vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
+	svga_id = vmw_read(dev_priv, SVGA_REG_ID);
+	if (svga_id == SVGA_ID_2) {
+		DRM_INFO("We have SVGA ID 2\n");
+	}
+
 	dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
 
 	if (dev_priv->capabilities & SVGA_CAP_GMR) {

Shouldn't this be something like:

vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2); 
	svga_id = vmw_read(dev_priv, SVGA_REG_ID);
	if (svga_id != SVGA_ID_2) {
		DRM_ERROR("Unsupported SVGA ID 0x%lx\n", svga_id);
		/* Bail */
	}
Signature · 14 lines
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#3 lore raw
Quoted 11 lines · Michel Dänzer
Quoted 10 lines · Jakob Bornecrantz

From: Peter Hanzel <[email protected]>

This fixes the driver not loading on older versions of VMware.

---
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 8 ++++++++

1 files changed, 8 insertions(+), 0 deletions(-)
Quoted 13 lines

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_driver_load(struct drm_device · line 213

Quoted 11 lines
drivers/gpu/drm/ renamed from drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -0

vmwgfx/vmwgfx_drv.c
index f47ff2c..8e68333 100644

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -0
@@ -209,6 +209,7 @@ static int vmw_driver_load(struct drm_device  
 *dev, unsigned long chipset)
 {
 	struct vmw_private *dev_priv;
 	int ret;
+ 	long svga_id;

This should be uint32_t rather than long.

Ah right.

Quoted 21 lines
Quoted 16 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -0
@@ -239,6 +240,13 @@ static int vmw_driver_load(struct drm_device  
 *dev, unsigned long chipset)
 	dev_priv->mmio_start = pci_resource_start(dev->pdev, 2);
 
 	mutex_lock(&dev_priv->hw_mutex);
+
+	vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
+	svga_id = vmw_read(dev_priv, SVGA_REG_ID);
+	if (svga_id == SVGA_ID_2) {
+		DRM_INFO("We have SVGA ID 2\n");
+	}
+
 	dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
 
Quoted 1 line
	if (dev_priv->capabilities & SVGA_CAP_GMR) {

Shouldn't this be something like:

Quoted 6 lines
vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
	svga_id = vmw_read(dev_priv, SVGA_REG_ID);
	if (svga_id != SVGA_ID_2) {
		DRM_ERROR("Unsupported SVGA ID 0x%lx\n", svga_id);
		/* Bail */
	}

I guess its better to bail on old hardware that we haven't tested on.

I'll respin this patch.

Cheers Jakob.
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--