Module Name:    src
Committed By:   riastradh
Date:           Sun Sep  8 15:54:20 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/i915 [riastradh-drm2]: i915_dma.c
            intel_ringbuffer.c intel_ringbuffer.h
        src/sys/external/bsd/drm2/i915drm [riastradh-drm2]: intel_pm.c
Removed Files:
        src/sys/external/bsd/drm2/i915drm [riastradh-drm2]: intel_ringbuffer.c

Log Message:
Adapt the Intel ringbuffer code to NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1.2.24 -r1.1.1.1.2.25 \
    src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
cvs rdiff -u -r1.1.1.1.2.7 -r1.1.1.1.2.8 \
    src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.c
cvs rdiff -u -r1.1.1.1.2.6 -r1.1.1.1.2.7 \
    src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.h
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/external/bsd/drm2/i915drm/intel_pm.c
cvs rdiff -u -r1.1.2.2 -r0 \
    src/sys/external/bsd/drm2/i915drm/intel_ringbuffer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.1.1.1.2.24 src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.1.1.1.2.25
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.1.1.1.2.24	Sun Sep  8 15:34:06 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c	Sun Sep  8 15:54:20 2013
@@ -239,19 +239,11 @@ static int i915_dma_resume(struct drm_de
 
 	DRM_DEBUG_DRIVER("%s\n", __func__);
 
-#ifdef __NetBSD__
-	if (!ring->virtual_start_mapped) {
-		DRM_ERROR("can not ioremap virtual address for"
-			  " ring buffer\n");
-		return -ENOMEM;
-	}
-#else
 	if (ring->virtual_start == NULL) {
 		DRM_ERROR("can not ioremap virtual address for"
 			  " ring buffer\n");
 		return -ENOMEM;
 	}
-#endif
 
 	/* Program Hardware Status Page */
 	if (!ring->status_page.page_addr) {
@@ -834,17 +826,10 @@ static int i915_irq_emit(struct drm_devi
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return -ENODEV;
 
-#ifdef __NetBSD__
-	if (!dev_priv || !LP_RING(dev_priv)->virtual_start_mapped) {
-		DRM_ERROR("called with no initialization\n");
-		return -EINVAL;
-	}
-#else
 	if (!dev_priv || !LP_RING(dev_priv)->virtual_start) {
 		DRM_ERROR("called with no initialization\n");
 		return -EINVAL;
 	}
-#endif
 
 	RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
 

Index: src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.c:1.1.1.1.2.7 src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.c:1.1.1.1.2.8
--- src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.c:1.1.1.1.2.7	Sun Sep  8 15:42:48 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.c	Sun Sep  8 15:54:20 2013
@@ -464,7 +464,12 @@ init_pipe_control(struct intel_ring_buff
 		goto err_unref;
 
 	pc->gtt_offset = obj->gtt_offset;
+#ifdef __NetBSD__
+	pc->cpu_page = kmap(container_of(TAILQ_FIRST(&obj->igo_pageq),
+		struct page, p_vmp));
+#else
 	pc->cpu_page =  kmap(sg_page(obj->pages->sgl));
+#endif
 	if (pc->cpu_page == NULL)
 		goto err_unpin;
 
@@ -492,7 +497,11 @@ cleanup_pipe_control(struct intel_ring_b
 
 	obj = pc->obj;
 
+#ifdef __NetBSD__
+	kunmap(container_of(TAILQ_FIRST(&obj->igo_pageq), struct page, p_vmp));
+#else
 	kunmap(sg_page(obj->pages->sgl));
+#endif
 	i915_gem_object_unpin(obj);
 	drm_gem_object_unreference(&obj->base);
 
@@ -1067,7 +1076,11 @@ static void cleanup_status_page(struct i
 	if (obj == NULL)
 		return;
 
+#ifdef __NetBSD__
+	kunmap(container_of(TAILQ_FIRST(&obj->igo_pageq), struct page, p_vmp));
+#else
 	kunmap(sg_page(obj->pages->sgl));
+#endif
 	i915_gem_object_unpin(obj);
 	drm_gem_object_unreference(&obj->base);
 	ring->status_page.obj = NULL;
@@ -1094,7 +1107,13 @@ static int init_status_page(struct intel
 	}
 
 	ring->status_page.gfx_addr = obj->gtt_offset;
+#ifdef __NetBSD__
+	ring->status_page.page_addr =
+	    kmap(container_of(TAILQ_FIRST(&obj->igo_pageq), struct page,
+		    p_vmp));
+#else
 	ring->status_page.page_addr = kmap(sg_page(obj->pages->sgl));
+#endif
 	if (ring->status_page.page_addr == NULL) {
 		ret = -ENOMEM;
 		goto err_unpin;
@@ -1195,22 +1214,17 @@ static int intel_init_ring_buffer(struct
 	ring->virtual_start_map.flags |= _DRM_KERNEL;
 	ring->virtual_start_map.flags |= _DRM_WRITE_COMBINING;
 	ring->virtual_start_map.flags |= _DRM_DRIVER;
-	ret = drm_ioremap(dev, &ring->virtual_start_map);
-	if (ret) {
-		DRM_ERROR("failed to map ring buffer\n");
-		goto err_unpin;
-	}
-	ring->virtual_start_mapped = true;
+	ring->virtual_start = drm_ioremap(dev, &ring->virtual_start_map);
 #else
 	ring->virtual_start =
 		ioremap_wc(dev_priv->mm.gtt->gma_bus_addr + obj->gtt_offset,
 			   ring->size);
+#endif
 	if (ring->virtual_start == NULL) {
 		DRM_ERROR("Failed to map ringbuffer.\n");
 		ret = -EINVAL;
 		goto err_unpin;
 	}
-#endif
 
 	ret = ring->init(ring);
 	if (ret)
@@ -1229,7 +1243,7 @@ static int intel_init_ring_buffer(struct
 err_unmap:
 #ifdef __NetBSD__
 	drm_iounmap(dev, &ring->virtual_start_map);
-	ring->virtual_start_mapped = false;
+	ring->virtual_start = NULL;
 #else
 	iounmap(ring->virtual_start);
 #endif
@@ -1262,7 +1276,7 @@ void intel_cleanup_ring_buffer(struct in
 
 #ifdef __NetBSD__
 	drm_iounmap(dev_priv->dev, &ring->virtual_start_map);
-	ring->virtual_start_mapped = false;
+	ring->virtual_start = NULL;
 #else
 	iounmap(ring->virtual_start);
 #endif
@@ -1388,6 +1402,18 @@ static int ring_wait_for_space(struct in
 	return -EBUSY;
 }
 
+#ifdef __NetBSD__		/* XXX */
+#  define	__iomem	__ring_iomem
+
+static inline void
+iowrite32(uint32_t value, uint32_t __ring_iomem *ptr)
+{
+
+	__insn_barrier();
+	*ptr = value;
+}
+#endif
+
 static int intel_wrap_ring_buffer(struct intel_ring_buffer *ring)
 {
 	uint32_t __iomem *virt;
@@ -1399,7 +1425,8 @@ static int intel_wrap_ring_buffer(struct
 			return ret;
 	}
 
-	virt = ring->virtual_start + ring->tail;
+	virt = (void __iomem *)((char __iomem *)ring->virtual_start +
+	    ring->tail);
 	rem /= 4;
 	while (rem--)
 		iowrite32(MI_NOOP, virt++);
@@ -1410,6 +1437,8 @@ static int intel_wrap_ring_buffer(struct
 	return 0;
 }
 
+#undef	__iomem
+
 int intel_ring_idle(struct intel_ring_buffer *ring)
 {
 	u32 seqno;
@@ -1763,12 +1792,11 @@ int intel_render_ring_init_dri(struct dr
 	ring->virtual_start_map.flags |= _DRM_KERNEL;
 	ring->virtual_start_map.flags |= _DRM_WRITE_COMBINING;
 	ring->virtual_start_map.flags |= _DRM_DRIVER;
-	ret = drm_ioremap(dev, &ring->virtual_start_map);
-	if (ret) {
+	ring->virtual_start = drm_ioremap(dev, &ring->virtual_start_map);
+	if (ring->virtual_start == NULL) {
 		DRM_ERROR("cannot ioremap virtual address for ring buffer\n");
-		return ret;
+		return -EIO;
 	}
-	ring->virtual_start_mapped = true;
 #else
 	ring->virtual_start = ioremap_wc(start, size);
 	if (ring->virtual_start == NULL) {

Index: src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.h:1.1.1.1.2.6 src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.h:1.1.1.1.2.7
--- src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.h:1.1.1.1.2.6	Wed Jul 24 03:06:00 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/intel_ringbuffer.h	Sun Sep  8 15:54:20 2013
@@ -39,6 +39,10 @@ struct  intel_hw_status_page {
 #define I915_READ_SYNC_0(ring) I915_READ(RING_SYNC_0((ring)->mmio_base))
 #define I915_READ_SYNC_1(ring) I915_READ(RING_SYNC_1((ring)->mmio_base))
 
+#ifdef __NetBSD__
+#  define	__ring_iomem
+#endif
+
 struct  intel_ring_buffer {
 	const char	*name;
 	enum intel_ring_id {
@@ -50,7 +54,7 @@ struct  intel_ring_buffer {
 	u32		mmio_base;
 #ifdef __NetBSD__
 	struct drm_local_map	virtual_start_map;
-	bool			virtual_start_mapped;
+	void __ring_iomem	*virtual_start;
 #else
 	void		__iomem *virtual_start;
 #endif

Index: src/sys/external/bsd/drm2/i915drm/intel_pm.c
diff -u src/sys/external/bsd/drm2/i915drm/intel_pm.c:1.1.2.4 src/sys/external/bsd/drm2/i915drm/intel_pm.c:1.1.2.5
--- src/sys/external/bsd/drm2/i915drm/intel_pm.c:1.1.2.4	Wed Jul 24 04:02:12 2013
+++ src/sys/external/bsd/drm2/i915drm/intel_pm.c	Sun Sep  8 15:54:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_pm.c,v 1.1.2.4 2013/07/24 04:02:12 riastradh Exp $	*/
+/*	$NetBSD: intel_pm.c,v 1.1.2.5 2013/09/08 15:54:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 /* intel_pm.c stubs */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_pm.c,v 1.1.2.4 2013/07/24 04:02:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_pm.c,v 1.1.2.5 2013/09/08 15:54:20 riastradh Exp $");
 
 #include "i915_drv.h"
 
@@ -112,6 +112,12 @@ gen6_set_rps(struct drm_device *dev, u8 
 /* XXX END KLUDGEY COPYPASTA FROM intel_pm.c */
 
 void
+i915_update_gfx_val(struct drm_i915_private *dev_priv)
+{
+	KASSERT(dev_priv->info->gen != 5); /* XXX gen<6 */
+}
+
+void
 intel_disable_fbc(struct drm_device *dev __unused)
 {
 }

Reply via email to