Pekka Paalanen
2009-Aug-02 15:12 UTC
[Nouveau] [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(). Signed-off-by: Pekka Paalanen <pq at iki.fi> --- 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(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 5477dc0..c6143b8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -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) { diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.c b/drivers/gpu/drm/nouveau/nouveau_hw.c index 295b876..6f55f55 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hw.c +++ b/drivers/gpu/drm/nouveau/nouveau_hw.c @@ -537,13 +537,33 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head) * vga font save/restore */ +static void nouveau_vga_font_io(struct drm_device *dev, + void __iomem *iovram, + bool save, unsigned plane) +{ + struct drm_nouveau_private *dev_priv = dev->dev_private; + unsigned i; + + NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 1 << plane); + NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, plane); + for (i = 0; i < 16384; i++) { + if (save) { + dev_priv->saved_vga_font[plane][i] + ioread32_native(iovram + i * 4); + } else { + iowrite32_native(dev_priv->saved_vga_font[plane][i], + iovram + i * 4); + } + } +} + void nouveau_hw_save_vga_fonts(struct drm_device *dev, bool save) { - struct drm_nouveau_private *dev_priv = dev->dev_private; uint8_t misc, gr4, gr5, gr6, seq2, seq4; bool graphicsmode; - int i; + unsigned plane; + void __iomem *iovram; if (nv_two_heads(dev)) NVSetOwner(dev, 0); @@ -552,10 +572,19 @@ nouveau_hw_save_vga_fonts(struct drm_device *dev, bool save) graphicsmode = NVReadVgaAttr(dev, 0, NV_CIO_AR_MODE_INDEX) & 1; NVSetEnablePalette(dev, 0, false); - if (graphicsmode) /* graphics mode => framebuffer => no need to save */ + if (graphicsmode) /* graphics mode => framebuffer => no need to save */ return; NV_INFO(dev, "%sing VGA fonts\n", save ? "Sav" : "Restor"); + + /* map first 64KiB of VRAM, holds VGA fonts etc */ + iovram = ioremap(pci_resource_start(dev->pdev, 1), 65536); + if (!iovram) { + NV_ERROR(dev, "Failed to map VRAM, " + "cannot save/restore VGA fonts.\n"); + return; + } + if (nv_two_heads(dev)) NVBlankScreen(dev, 1, true); NVBlankScreen(dev, 0, true); @@ -573,41 +602,9 @@ nouveau_hw_save_vga_fonts(struct drm_device *dev, bool save) NVWriteVgaGr(dev, 0, NV_VIO_GX_MODE_INDEX, 0x0); NVWriteVgaGr(dev, 0, NV_VIO_GX_MISC_INDEX, 0x5); - /* store font in plane 0 */ - NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 0x1); - NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, 0x0); - for (i = 0; i < 16384; i++) - if (save) - dev_priv->saved_vga_font[0][i] = nv_rf32(dev, i * 4); - else - nv_wf32(dev, i * 4, dev_priv->saved_vga_font[0][i]); - - /* store font in plane 1 */ - NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 0x2); - NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, 0x1); - for (i = 0; i < 16384; i++) - if (save) - dev_priv->saved_vga_font[1][i] = nv_rf32(dev, i * 4); - else - nv_wf32(dev, i * 4, dev_priv->saved_vga_font[1][i]); - - /* store font in plane 2 */ - NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 0x4); - NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, 0x2); - for (i = 0; i < 16384; i++) - if (save) - dev_priv->saved_vga_font[2][i] = nv_rf32(dev, i * 4); - else - nv_wf32(dev, i * 4, dev_priv->saved_vga_font[2][i]); - - /* store font in plane 3 */ - NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 0x8); - NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, 0x3); - for (i = 0; i < 16384; i++) - if (save) - dev_priv->saved_vga_font[3][i] = nv_rf32(dev, i * 4); - else - nv_wf32(dev, i * 4, dev_priv->saved_vga_font[3][i]); + /* store font in planes 0..3 */ + for (plane = 0; plane < 4; plane++) + nouveau_vga_font_io(dev, iovram, save, plane); /* restore control regs */ NVWritePRMVIO(dev, 0, NV_PRMVIO_MISC__WRITE, misc); @@ -620,6 +617,8 @@ nouveau_hw_save_vga_fonts(struct drm_device *dev, bool save) if (nv_two_heads(dev)) NVBlankScreen(dev, 1, false); NVBlankScreen(dev, 0, false); + + iounmap(iovram); } /* diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index 93d14f3..ace8beb 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c @@ -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; -- 1.6.3.3
Pekka Paalanen
2009-Aug-02 15:12 UTC
[Nouveau] [PATCH 2/4] drm/nouveau: cleanup in nouveau_bo_unmap()
ttm_bo_kunmap() already checks for map->virtual and sets it to NULL. Signed-off-by: Pekka Paalanen <pq at iki.fi> --- drivers/gpu/drm/nouveau/nouveau_bo.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 609118c..de4ca71 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -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 * -- 1.6.3.3
Pekka Paalanen
2009-Aug-02 15:12 UTC
[Nouveau] [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. Signed-off-by: Pekka Paalanen <pq at iki.fi> --- 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(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index de4ca71..052ec56 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -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; diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index c6143b8..01c615a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -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 **); diff --git a/drivers/gpu/drm/nouveau/nouveau_fifo.c b/drivers/gpu/drm/nouveau/nouveau_fifo.c index 58cef14..9d96ce6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fifo.c +++ b/drivers/gpu/drm/nouveau/nouveau_fifo.c @@ -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) { diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 670348b..a54fce4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -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; diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c index c732fbe..860cf0d 100644 --- a/drivers/gpu/drm/nouveau/nv04_crtc.c +++ b/drivers/gpu/drm/nouveau/nv04_crtc.c @@ -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); diff --git a/drivers/gpu/drm/nouveau/nv50_crtc.c b/drivers/gpu/drm/nouveau/nv50_crtc.c index 81c53c4..32d423d 100644 --- a/drivers/gpu/drm/nouveau/nv50_crtc.c +++ b/drivers/gpu/drm/nouveau/nv50_crtc.c @@ -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); diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 2ab1685..9b22a3d 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c @@ -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); diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c index 062d085..f2401b9 100644 --- a/drivers/gpu/drm/nouveau/nv50_instmem.c +++ b/drivers/gpu/drm/nouveau/nv50_instmem.c @@ -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); -- 1.6.3.3
Maybe Matching Threads
- [PATCH] nouveau: Fix declarations with incorrect variables.
- [PATCH 0/3] drm/tegra: Add support for fence FDs
- [PATCH] Use nanosleep instead of usleep when waiting the hardware.
- [Bug 14284] New: frequent DMA queue hangs on NV34 on powerpc
- nouveau git + v3.2-rc2 + NV18 Oops