Skip to contentSkip to conversation

drm/nouveau: refactor VGA font save/restore

PATCH In review Pekka Paalanen 1 participant 6 messages Aug 2, 2009 – Aug 3, 2009 4 messages not in the archive

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

PATCH 1/4 drm/nouveau: refactor VGA font save/restore

Remove drm_nouveau_private::fb member and map the piece of VRAM only when accessing VGA fonts.

Collect copied code into the static function nouveau_vga_font_io().

---
 drivers/gpu/drm/nouveau/nouveau_drv.h   |   17 -------
 drivers/gpu/drm/nouveau/nouveau_hw.c    |   75 +++++++++++++++----------------
 drivers/gpu/drm/nouveau/nouveau_state.c |    8 ---
 3 files changed, 37 insertions(+), 63 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +0 -17
index 5477dc0..c6143b8 100644
@@ -461,7 +461,6 @@ struct drm_nouveau_private {
 	int flags;
 
 	void __iomem *mmio;
-	void __iomem *fb;
 	void __iomem *ramin;
 	uint32_t ramin_size;
 
@@ -1014,22 +1013,6 @@ static inline void nv_wr08(struct drm_device *dev, unsigned reg, u8 val)
 #define nv_wait(reg,mask,val) nouveau_wait_until(dev, 2000000000ULL, (reg),    \
 						 (mask), (val))
 
-/*
- * VRAM access for the first 64kB
- * see nouveau_state.c
- */
-static inline u32 nv_rf32(struct drm_device *dev, unsigned offset)
-{
-	struct drm_nouveau_private *dev_priv = dev->dev_private;
-	return ioread32_native(dev_priv->fb + offset);
-}
-
-static inline void nv_wf32(struct drm_device *dev, unsigned offset, u32 val)
-{
-	struct drm_nouveau_private *dev_priv = dev->dev_private;
-	iowrite32_native(val, dev_priv->fb + offset);
-}
-
 /* PRAMIN access */
 static inline u32 nv_ri32(struct drm_device *dev, unsigned offset)
 {
drivers/gpu/drm/nouveau/nouveau_hw.c +37 -38

107 lines not on this page · raw message

drivers/gpu/drm/nouveau/nouveau_state.c +0 -8
index 93d14f3..ace8beb 100644
@@ -590,13 +590,6 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 		}
 	}
 
-	/* map first 64KiB of VRAM, holds VGA fonts etc */
-	dev_priv->fb = ioremap(pci_resource_start(dev->pdev, 1), 65536);
-	if (!dev_priv->fb) {
-		NV_ERROR(dev, "Failed to map FB BAR\n");
-		return -ENOMEM;
-	}
-
 	nouveau_OF_copy_vbios_to_ramin(dev);
 
 	/* Special flags */
@@ -648,7 +641,6 @@ int nouveau_unload(struct drm_device *dev)
 
 	iounmap(dev_priv->mmio);
 	iounmap(dev_priv->ramin);
-	iounmap(dev_priv->fb);
 
 	kfree(dev_priv);
 	dev->dev_private = NULL;
Signature · 1 line
1.6.3.3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 2/4 drm/nouveau: cleanup in nouveau_bo_unmap()

ttm_bo_kunmap() already checks for map->virtual and sets it to NULL.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -4
index 609118c..de4ca71 100644
@@ -169,10 +169,7 @@ nouveau_bo_map(struct nouveau_bo *nvbo)
 void
 nouveau_bo_unmap(struct nouveau_bo *nvbo)
 {
-	if (nvbo->kmap.virtual) {
-		ttm_bo_kunmap(&nvbo->kmap);
-		nvbo->kmap.virtual = NULL;
-	}
+	ttm_bo_kunmap(&nvbo->kmap);
 }
 
 static struct ttm_backend *
Signature · 1 line
1.6.3.3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH 3/4 drm/nouveau: remove unused arg from nouveau_bo_new()

nouveau_bo_new() took struct nouveau_channel *chan as a parameter, yet it was not used (it was set and then reset to NULL). Remove the unused parameter (which was almost always NULL anyway).

No need to set nvbo->channel = NULL since kzalloc already zeros it.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c   |    4 +---
 drivers/gpu/drm/nouveau/nouveau_drv.h  |    2 +-
 drivers/gpu/drm/nouveau/nouveau_fifo.c |    2 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c  |    2 +-
 drivers/gpu/drm/nouveau/nv04_crtc.c    |    2 +-
 drivers/gpu/drm/nouveau/nv50_crtc.c    |    2 +-
 drivers/gpu/drm/nouveau/nv50_display.c |    2 +-
 drivers/gpu/drm/nouveau/nv50_instmem.c |    2 +-
 8 files changed, 8 insertions(+), 10 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -3
index de4ca71..052ec56 100644
@@ -52,7 +52,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
 }
 
 int
-nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
+nouveau_bo_new(struct drm_device *dev,
 	       int size, int align, uint32_t flags, uint32_t tile_mode,
 	       uint32_t tile_flags, bool no_vm, bool mappable,
 	       struct nouveau_bo **pnvbo)
@@ -81,11 +81,9 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
 			align = (65536 / PAGE_SIZE);
 	}
 
-	nvbo->channel = chan;
 	ret = ttm_buffer_object_init(&dev_priv->ttm.bdev, &nvbo->bo, size,
 				     ttm_bo_type_device, flags, align,
 				     0, false, NULL, size, nouveau_bo_del_ttm);
-	nvbo->channel = NULL;
 	if (ret) {
 		/* ttm will call nouveau_bo_del_ttm if it fails.. */
 		return ret;
drivers/gpu/drm/nouveau/nouveau_drv.h +1 -1
index c6143b8..01c615a 100644
@@ -918,7 +918,7 @@ extern struct nouveau_connector *nouveau_encoder_connector_get(
 
 /* nouveau_bo.c */
 extern struct ttm_bo_driver nouveau_bo_driver;
-extern int nouveau_bo_new(struct drm_device *, struct nouveau_channel *,
+extern int nouveau_bo_new(struct drm_device *,
 			  int size, int align, uint32_t flags,
 			  uint32_t tile_mode, uint32_t tile_flags,
 			  bool no_vm, bool mappable, struct nouveau_bo **);
drivers/gpu/drm/nouveau/nouveau_fifo.c +1 -1
index 58cef14..9d96ce6 100644
@@ -256,7 +256,7 @@ nouveau_fifo_user_pushbuf_alloc(struct drm_device *dev)
 	if (!config->cmdbuf.size || config->cmdbuf.size < pb_min_size)
 		config->cmdbuf.size = 65536;
 
-	ret = nouveau_bo_new(dev, NULL, config->cmdbuf.size, 0,
+	ret = nouveau_bo_new(dev, config->cmdbuf.size, 0,
 			     config->cmdbuf.location, 0, 0x0000,
 			     false, true, &pushbuf);
 	if (ret) {
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -1
index 670348b..a54fce4 100644
@@ -68,7 +68,7 @@ nouveau_gem_new(struct drm_device *dev, struct nouveau_channel *chan,
 	struct nouveau_bo *nvbo;
 	int ret;
 
-	ret = nouveau_bo_new(dev, chan, size, align, flags, tile_mode,
+	ret = nouveau_bo_new(dev, size, align, flags, tile_mode,
 			     tile_flags, no_vm, mappable, pnvbo);
 	if (ret)
 		return ret;
drivers/gpu/drm/nouveau/nv04_crtc.c +1 -1
index c732fbe..860cf0d 100644
@@ -1118,7 +1118,7 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
 	drm_crtc_helper_add(&nv_crtc->base, &nv04_crtc_helper_funcs);
 	drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
 
-	ret = nouveau_bo_new(dev, NULL, 64*64*4, 0x100, TTM_PL_FLAG_VRAM,
+	ret = nouveau_bo_new(dev, 64 * 64 * 4, 0x100, TTM_PL_FLAG_VRAM,
 			     0, 0x0000, false, true, &nv_crtc->cursor.nvbo);
 	if (!ret) {
 		ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
drivers/gpu/drm/nouveau/nv50_crtc.c +1 -1
index 81c53c4..32d423d 100644
@@ -777,7 +777,7 @@ nv50_crtc_create(struct drm_device *dev, int index)
 	}
 	crtc->lut.depth = 0;
 
-	ret = nouveau_bo_new(dev, NULL, 4096, 0x100, TTM_PL_FLAG_VRAM,
+	ret = nouveau_bo_new(dev, 4096, 0x100, TTM_PL_FLAG_VRAM,
 			     0, 0x0000, false, true, &crtc->lut.nvbo);
 	if (!ret) {
 		ret = nouveau_bo_pin(crtc->lut.nvbo, TTM_PL_FLAG_VRAM);
drivers/gpu/drm/nouveau/nv50_display.c +1 -1
index 2ab1685..9b22a3d 100644
@@ -149,7 +149,7 @@ nv50_evo_channel_new(struct drm_device *dev, struct nouveau_channel **pchan)
 		return ret;
 	}
 
-	ret = nouveau_bo_new(dev, NULL, 4096, 0, TTM_PL_FLAG_VRAM, 0, 0,
+	ret = nouveau_bo_new(dev, 4096, 0, TTM_PL_FLAG_VRAM, 0, 0,
 			     false, true, &chan->pushbuf_bo);
 	if (ret == 0)
 		ret = nouveau_bo_pin(chan->pushbuf_bo, TTM_PL_FLAG_VRAM);
drivers/gpu/drm/nouveau/nv50_instmem.c +1 -1
index 062d085..f2401b9 100644
@@ -368,7 +368,7 @@ nv50_instmem_populate(struct drm_device *dev, struct nouveau_gpuobj *gpuobj,
 	if (*sz == 0)
 		return -EINVAL;
 
-	ret = nouveau_bo_new(dev, NULL, *sz, 0, TTM_PL_FLAG_VRAM, 0, 0x0000,
+	ret = nouveau_bo_new(dev, *sz, 0, TTM_PL_FLAG_VRAM, 0, 0x0000,
 			     true, false, &gpuobj->im_backing);
 	if (ret) {
 		NV_ERROR(dev, "error getting PRAMIN backing pages: %d\n", ret);
Signature · 1 line
1.6.3.3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

PATCH 4/4 drm/nouveau: detect bad iomem usage in TTM maps

kmap.virtual should not be used blindly, because it may be a kernel virtual pointer or an iomem cookie. Iomem cookies may not be dereferenced directly, they must be used via ioread32() etc. functions. Unfortunately x86 doesn't care too much, except for caching issues (barriers). Other arches may fail mysteriously.

Use the TTM API to get the virtual pointer from a map object, and check if the map type is as expected. This is not the fix but simply shows in how many places things are wrong.

TTM does not use __iomem attributes in the API and sparse yells its head off. Seems that TTM would need another set of access wrappers that use ttm_kmap_obj_virtual() and honour is_iomem.

---
 drivers/gpu/drm/nouveau/nouveau_dma.c   |   11 +++++++++--
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |    7 ++++++-
 drivers/gpu/drm/nouveau/nv04_crtc.c     |    9 +++++++--
 drivers/gpu/drm/nouveau/nv50_crtc.c     |    7 ++++++-
 drivers/gpu/drm/nouveau/nv50_display.c  |   11 +++++++++--
 5 files changed, 37 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dma.c +9 -2
index 7766af4..6d26c1e 100644
@@ -36,6 +36,7 @@ nouveau_dma_init(struct nouveau_channel *chan)
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
 	struct nouveau_gpuobj *m2mf = NULL;
 	int ret, i;
+	bool is_iomem;
 
 	/* Create NV_MEMORY_TO_MEMORY_FORMAT for buffer moves */
 	ret = nouveau_gpuobj_gr_new(chan, dev_priv->card_type < NV_50 ?
@@ -56,14 +57,20 @@ nouveau_dma_init(struct nouveau_channel *chan)
 	ret = nouveau_bo_map(chan->pushbuf_bo);
 	if (ret)
 		return ret;
-	chan->dma.pushbuf = chan->pushbuf_bo->kmap.virtual;
+	chan->dma.pushbuf = ttm_kmap_obj_virtual(&chan->pushbuf_bo->kmap,
+								&is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: chan->dma.pushbuf is iomem.\n");
 
 	/* Map M2MF notifier object - fbcon. */
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = nouveau_bo_map(chan->notifier_bo);
 		if (ret)
 			return ret;
-		chan->m2mf_ntfy_map  = chan->notifier_bo->kmap.virtual;
+		chan->m2mf_ntfy_map = ttm_kmap_obj_virtual(
+					&chan->notifier_bo->kmap, &is_iomem);
+		if (is_iomem)
+			NV_WARN(dev, "WARNING: chan->m2mf_ntfy is iomem.\n");
 		chan->m2mf_ntfy_map += chan->m2mf_ntfy;
 	}
 
drivers/gpu/drm/nouveau/nouveau_fbcon.c +6 -1
index 1511d6c..b7e6eb8 100644
@@ -505,6 +505,7 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
 	struct device *device = &dev->pdev->dev;
 	struct fb_fillrect rect;
 	int size, ret;
+	bool is_iomem;
 
 	mode_cmd.width = surface_width;
 	mode_cmd.height = surface_height;
@@ -573,7 +574,11 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
 	info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
 		      FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
 
-	info->screen_base = nouveau_fb->nvbo->kmap.virtual;
+	info->screen_base = ttm_kmap_obj_virtual(&nouveau_fb->nvbo->kmap,
+								&is_iomem);
+	if (!is_iomem)
+		NV_WARN(dev,
+			"WARNING: fbcon info->screen_base is not iomem.\n");
 	info->screen_size = size;
 
 	info->pseudo_palette = fb->pseudo_palette;
drivers/gpu/drm/nouveau/nv04_crtc.c +7 -2
index 860cf0d..a038a5f 100644
@@ -999,6 +999,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
 	struct drm_gem_object *gem;
 	uint32_t *src, *dst, pixel;
 	int ret = 0, alpha, i;
+	bool is_iomem;
 
 	if (width != 64 || height != 64)
 		return -EINVAL;
@@ -1016,8 +1017,12 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
 	ret = nouveau_bo_map(cursor);
 	if (ret)
 		goto out;
-	src = cursor->kmap.virtual;
-	dst = nv_crtc->cursor.nvbo->kmap.virtual;
+	src = ttm_kmap_obj_virtual(&cursor->kmap, &is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: nv04 cursor src is iomem.\n");
+	dst = ttm_kmap_obj_virtual(&nv_crtc->cursor.nvbo->kmap, &is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: nv04 cursor dst is iomem.\n");
 
 	/* nv11+ supports premultiplied (PM), or non-premultiplied (NPM) alpha
 	 * cursors (though NPM in combination with fp dithering may not work on
drivers/gpu/drm/nouveau/nv50_crtc.c +6 -1
index 32d423d..66e802b 100644
@@ -43,10 +43,15 @@ nv50_crtc_lut_load(struct nouveau_crtc *crtc)
 {
 	struct drm_device *dev = crtc->base.dev;
 	uint32_t index = 0, i;
-	void __iomem *lut = crtc->lut.nvbo->kmap.virtual;
+	bool is_iomem;
+	void __iomem *lut = ttm_kmap_obj_virtual(&crtc->lut.nvbo->kmap,
+								&is_iomem);
 
 	NV_DEBUG(dev, "\n");
 
+	if (!is_iomem)
+		NV_WARN(dev, "WARNING: nv50 lut is not iomem.\n");
+
 	/* 16 bits, red, green, blue, unused, total of 64 bits per index */
 	/* 10 bits lut, with 14 bits values. */
 	switch (crtc->lut.depth) {
drivers/gpu/drm/nouveau/nv50_display.c +9 -2
index 9b22a3d..72fce83 100644
@@ -187,6 +187,7 @@ nv50_display_init(struct drm_device *dev)
 	uint32_t val, ram_amount;
 	uint64_t start;
 	int i;
+	bool is_iomem;
 
 	NV_DEBUG(dev, "\n");
 
@@ -328,7 +329,10 @@ nv50_display_init(struct drm_device *dev)
 	evo->dma.put = 0;
 	evo->dma.cur = evo->dma.put;
 	evo->dma.free = evo->dma.max - evo->dma.cur;
-	evo->dma.pushbuf = evo->pushbuf_bo->kmap.virtual;
+	evo->dma.pushbuf = ttm_kmap_obj_virtual(&evo->pushbuf_bo->kmap,
+								&is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: evo->dma.pushbuf is iomem.\n");
 
 	RING_SPACE(evo, NOUVEAU_DMA_SKIPS);
 	for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
@@ -638,11 +642,14 @@ nv50_display_vblank_crtc_handler(struct drm_device *dev, int crtc)
 	struct nouveau_channel *chan;
 	struct list_head *entry, *tmp;
 	uint32_t *sem;
+	bool is_iomem;
 
 	list_for_each_safe(entry, tmp, &dev_priv->vbl_waiting) {
 		chan = list_entry(entry, struct nouveau_channel, nvsw.vbl_wait);
 
-		sem = chan->notifier_bo->kmap.virtual;
+		sem = ttm_kmap_obj_virtual(&chan->notifier_bo->kmap, &is_iomem);
+		if (is_iomem)
+			NV_WARN(dev, "WARNING: nv50 sem is iomem.\n");
 		sem[chan->nvsw.vblsem_offset] = chan->nvsw.vblsem_rval;
 
 		list_del(&chan->nvsw.vbl_wait);
Signature · 1 line
1.6.3.3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Re: [PATCH 4/4] drm/nouveau: detect bad iomem usage in TTM maps

Quoted 6 lines · On Sun, 2 Aug 2009 18:12:52 +0300 Pekka Paalanen…

kmap.virtual should not be used blindly, because it may be a kernel virtual pointer or an iomem cookie. Iomem cookies may not be dereferenced directly, they must be used via ioread32() etc. functions. Unfortunately x86 doesn't care too much, except for caching issues (barriers). Other arches may fail mysteriously.

From the kernel code purity point of view, this is clearly an error and should be fixed. OTOH, it does not seem to hurt much, does it?

How do we fix it?

Do we need special routines that take is_iomem into account? Are some bos such, that they are always iomem or never iomem, in which case a WARN_ON could suffice?

When I start KMS, g86gl, X, I get the following:

[   84.711009] nouveau 0000:01:00.0: Allocating FIFO number 1
[   84.724325] nouveau 0000:01:00.0: WARNING: chan->m2mf_ntfy is iomem.
[   84.724328] nouveau 0000:01:00.0: nouveau_fifo_alloc: initialised FIFO 1
[   84.726196] nouveau 0000:01:00.0: Detected a DVI-D connector
[   86.002826] nouveau 0000:01:00.0: WARNING: evo->dma.pushbuf is iomem.
[   86.106518] allocated 1440x900 fb: 0x40230000, bo ffff88003d156400
[   86.654361] nouveau 0000:01:00.0: Allocating FIFO number 2
[   86.680615] nouveau 0000:01:00.0: WARNING: chan->m2mf_ntfy is iomem.
[   86.680622] nouveau 0000:01:00.0: nouveau_fifo_alloc: initialised FIFO 2
Quoted 167 lines

Use the TTM API to get the virtual pointer from a map object, and check if the map type is as expected. This is not the fix but simply shows in how many places things are wrong.

TTM does not use __iomem attributes in the API and sparse yells its head off. Seems that TTM would need another set of access wrappers that use ttm_kmap_obj_virtual() and honour is_iomem.

---
 drivers/gpu/drm/nouveau/nouveau_dma.c   |   11 +++++++++--
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |    7 ++++++-
 drivers/gpu/drm/nouveau/nv04_crtc.c     |    9 +++++++--
 drivers/gpu/drm/nouveau/nv50_crtc.c     |    7 ++++++-
 drivers/gpu/drm/nouveau/nv50_display.c  |   11 +++++++++--
 5 files changed, 37 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dma.c +9 -2
index 7766af4..6d26c1e 100644
@@ -36,6 +36,7 @@ nouveau_dma_init(struct nouveau_channel *chan)
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
 	struct nouveau_gpuobj *m2mf = NULL;
 	int ret, i;
+	bool is_iomem;
 
 	/* Create NV_MEMORY_TO_MEMORY_FORMAT for buffer moves */
 	ret = nouveau_gpuobj_gr_new(chan, dev_priv->card_type < NV_50 ?
@@ -56,14 +57,20 @@ nouveau_dma_init(struct nouveau_channel *chan)
 	ret = nouveau_bo_map(chan->pushbuf_bo);
 	if (ret)
 		return ret;
-	chan->dma.pushbuf = chan->pushbuf_bo->kmap.virtual;
+	chan->dma.pushbuf = ttm_kmap_obj_virtual(&chan->pushbuf_bo->kmap,
+								&is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: chan->dma.pushbuf is iomem.\n");
 
 	/* Map M2MF notifier object - fbcon. */
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = nouveau_bo_map(chan->notifier_bo);
 		if (ret)
 			return ret;
-		chan->m2mf_ntfy_map  = chan->notifier_bo->kmap.virtual;
+		chan->m2mf_ntfy_map = ttm_kmap_obj_virtual(
+					&chan->notifier_bo->kmap, &is_iomem);
+		if (is_iomem)
+			NV_WARN(dev, "WARNING: chan->m2mf_ntfy is iomem.\n");
 		chan->m2mf_ntfy_map += chan->m2mf_ntfy;
 	}
 
drivers/gpu/drm/nouveau/nouveau_fbcon.c +6 -1
index 1511d6c..b7e6eb8 100644
@@ -505,6 +505,7 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
 	struct device *device = &dev->pdev->dev;
 	struct fb_fillrect rect;
 	int size, ret;
+	bool is_iomem;
 
 	mode_cmd.width = surface_width;
 	mode_cmd.height = surface_height;
@@ -573,7 +574,11 @@ static int nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
 	info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
 		      FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
 
-	info->screen_base = nouveau_fb->nvbo->kmap.virtual;
+	info->screen_base = ttm_kmap_obj_virtual(&nouveau_fb->nvbo->kmap,
+								&is_iomem);
+	if (!is_iomem)
+		NV_WARN(dev,
+			"WARNING: fbcon info->screen_base is not iomem.\n");
 	info->screen_size = size;
 
 	info->pseudo_palette = fb->pseudo_palette;
drivers/gpu/drm/nouveau/nv04_crtc.c +7 -2
index 860cf0d..a038a5f 100644
@@ -999,6 +999,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
 	struct drm_gem_object *gem;
 	uint32_t *src, *dst, pixel;
 	int ret = 0, alpha, i;
+	bool is_iomem;
 
 	if (width != 64 || height != 64)
 		return -EINVAL;
@@ -1016,8 +1017,12 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
 	ret = nouveau_bo_map(cursor);
 	if (ret)
 		goto out;
-	src = cursor->kmap.virtual;
-	dst = nv_crtc->cursor.nvbo->kmap.virtual;
+	src = ttm_kmap_obj_virtual(&cursor->kmap, &is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: nv04 cursor src is iomem.\n");
+	dst = ttm_kmap_obj_virtual(&nv_crtc->cursor.nvbo->kmap, &is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: nv04 cursor dst is iomem.\n");
 
 	/* nv11+ supports premultiplied (PM), or non-premultiplied (NPM) alpha
 	 * cursors (though NPM in combination with fp dithering may not work on
drivers/gpu/drm/nouveau/nv50_crtc.c +6 -1
index 32d423d..66e802b 100644
@@ -43,10 +43,15 @@ nv50_crtc_lut_load(struct nouveau_crtc *crtc)
 {
 	struct drm_device *dev = crtc->base.dev;
 	uint32_t index = 0, i;
-	void __iomem *lut = crtc->lut.nvbo->kmap.virtual;
+	bool is_iomem;
+	void __iomem *lut = ttm_kmap_obj_virtual(&crtc->lut.nvbo->kmap,
+								&is_iomem);
 
 	NV_DEBUG(dev, "\n");
 
+	if (!is_iomem)
+		NV_WARN(dev, "WARNING: nv50 lut is not iomem.\n");
+
 	/* 16 bits, red, green, blue, unused, total of 64 bits per index */
 	/* 10 bits lut, with 14 bits values. */
 	switch (crtc->lut.depth) {
drivers/gpu/drm/nouveau/nv50_display.c +9 -2
index 9b22a3d..72fce83 100644
@@ -187,6 +187,7 @@ nv50_display_init(struct drm_device *dev)
 	uint32_t val, ram_amount;
 	uint64_t start;
 	int i;
+	bool is_iomem;
 
 	NV_DEBUG(dev, "\n");
 
@@ -328,7 +329,10 @@ nv50_display_init(struct drm_device *dev)
 	evo->dma.put = 0;
 	evo->dma.cur = evo->dma.put;
 	evo->dma.free = evo->dma.max - evo->dma.cur;
-	evo->dma.pushbuf = evo->pushbuf_bo->kmap.virtual;
+	evo->dma.pushbuf = ttm_kmap_obj_virtual(&evo->pushbuf_bo->kmap,
+								&is_iomem);
+	if (is_iomem)
+		NV_WARN(dev, "WARNING: evo->dma.pushbuf is iomem.\n");
 
 	RING_SPACE(evo, NOUVEAU_DMA_SKIPS);
 	for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
@@ -638,11 +642,14 @@ nv50_display_vblank_crtc_handler(struct drm_device *dev, int crtc)
 	struct nouveau_channel *chan;
 	struct list_head *entry, *tmp;
 	uint32_t *sem;
+	bool is_iomem;
 
 	list_for_each_safe(entry, tmp, &dev_priv->vbl_waiting) {
 		chan = list_entry(entry, struct nouveau_channel, nvsw.vbl_wait);
 
-		sem = chan->notifier_bo->kmap.virtual;
+		sem = ttm_kmap_obj_virtual(&chan->notifier_bo->kmap, &is_iomem);
+		if (is_iomem)
+			NV_WARN(dev, "WARNING: nv50 sem is iomem.\n");
 		sem[chan->nvsw.vblsem_offset] = chan->nvsw.vblsem_rval;
 
 		list_del(&chan->nvsw.vbl_wait);
Signature · 1 line
1.6.3.3
Signature · 2 lines
Pekka Paalanen
http://www.iki.fi/pq/