patch 0/4: DRM MMIO accessor cleanup
Subsystems (3)
Hi,
this is continuation for the MMIO accessor rewrite and cleanup. I am currently running nv28 with these patches applied, but I cannot test on PPC.
Please, review and comment. If the direction is good, I'll do the same to INSTANCE_{RD,WR} as I did for nv_{rd,wr}32, and change PRAMIN from drm_local_map to simple ioremap.
Can the same be done for channel specific mappings, that is nvchan_{rd,wr}32?
The macros nv_{in,out}32 are very close to removal now.
It also looks like nouveau_load() is in need of serious error path review for resource leakage. And maybe refactorization, too, into small functions.
- pq
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 drm/nouveau: change MMIO map to simple ioremap
This removes the ugliness of using drm_local_map. The use of ioremap() is identical to what drm_addmap()/drm_rmmap() did.
Is ioremap() the right thing or should we use e.g. ioremap_uc()? The ioremap API has been reworked in the past, and some assumptions changed in the mapping caching type.
--- drivers/gpu/drm/nouveau/nouveau_drv.h | 14 +++++++------- drivers/gpu/drm/nouveau/nouveau_state.c | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +7 -7
@@ -447,7 +447,7 @@ struct drm_nouveau_private {int chipset;int flags; -struct drm_local_map *mmio; +void __iomem *mmio;struct drm_local_map *fb;struct drm_local_map *ramin;
@@ -975,38 +975,38 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *,static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg) {struct drm_nouveau_private *dev_priv = dev->dev_private; -return in_be32 ((void __force __iomem *)dev_priv->mmio->handle + reg); +return in_be32 (dev_priv->mmio + reg); }static inline void nv_wr32 (struct drm_device *dev,unsigned reg,u32 val) {struct drm_nouveau_private *dev_priv = dev->dev_private; -out_be32 ((void __force __iomem *)dev_priv->mmio->handle + reg, val); +out_be32 (dev_priv->mmio + reg, val); }#else static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg) {struct drm_nouveau_private *dev_priv = dev->dev_private; -return readl ((void __force __iomem *)dev_priv->mmio->handle + reg); +return readl (dev_priv->mmio + reg); }static inline void nv_wr32 (struct drm_device *dev,unsigned reg,u32 val) {struct drm_nouveau_private *dev_priv = dev->dev_private; -writel (val, (void __force __iomem *)dev_priv->mmio->handle + reg); +writel (val, dev_priv->mmio + reg); }#endif /* not __powerpc__ */ static inline u8 nv_rd08 (struct drm_device *dev,unsigned reg) {struct drm_nouveau_private *dev_priv = dev->dev_private; -return readb ((void __force __iomem *)dev_priv->mmio->handle + reg); +return readb (dev_priv->mmio + reg); }static inline void nv_wr08 (struct drm_device *dev,unsigned reg,u8 val) {struct drm_nouveau_private *dev_priv = dev->dev_private; -writeb (val, (void __force __iomem *)dev_priv->mmio->handle + reg); +writeb (val, dev_priv->mmio + reg); }#define nv_wait (reg,mask,val) nouveau_wait_until(dev, 2000000000ULL, (reg), \
drivers/gpu/drm/nouveau/nouveau_state.c +11 -10
@@ -454,6 +454,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)#endif uint32_t reg0;uint8_t architecture =0 ; +resource_size_t mmio_start_offs;int ret; dev_priv =kzalloc (sizeof (*dev_priv),GFP_KERNEL );
@@ -474,16 +475,15 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)/* resource 6 is bios */ /* map the mmio regs */ - ret =drm_addmap (dev,drm_get_resource_start (dev,0 ), -0x00800000 , _DRM_REGISTERS, _DRM_READ_ONLY | - _DRM_DRIVER, &dev_priv->mmio); -if (ret) { -NV_ERROR (dev,"Unable to initialize the mmio mapping (%d). " -"Please report your setup to " DRIVER_EMAIL "\n" , - ret); + mmio_start_offs =pci_resource_start (dev->pdev,0 ); + dev_priv->mmio =ioremap (mmio_start_offs,0x00800000 ); +if (!dev_priv->mmio) { +NV_ERROR (dev,"Unable to initialize the mmio mapping. " +"Please report your setup to " DRIVER_EMAIL "\n" );return -EINVAL ; } -NV_DEBUG (dev,"regs mapped ok at 0x%lx\n" , (unsigned long )dev_priv->mmio->offset); +NV_DEBUG (dev,"regs mapped ok at 0x%llx\n" , + (unsigned long long )mmio_start_offs);#if defined(__powerpc__)/* Put the card in BE mode if it's not */
@@ -538,7 +538,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev_priv->card_type =NV_UNKNOWN ; } -NV_INFO (dev,"Detected an NV%d generation card (0x%08x)\n" , dev_priv->card_type,reg0); +NV_INFO (dev,"Detected an NV%d generation card (0x%08x)\n" , + dev_priv->card_type, reg0);if (dev_priv->card_type ==NV_UNKNOWN ) {return -EINVAL ;
@@ -653,7 +654,7 @@ int nouveau_unload(struct drm_device *dev)nouveau_close (dev); } -drm_rmmap (dev, dev_priv->mmio); +iounmap (dev_priv->mmio);drm_rmmap (dev, dev_priv->ramin);drm_rmmap (dev, dev_priv->fb);
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/4 drm/nouveau: use proper IO accessors on PPC
Use the generic io{read,write}32be() functions on big-endian instead of the PPC-specific private {in,out}_be32(), which are not meant to be used with PCI devices.
While we are at it, change all #ifdef __powerpc__ that are really just for endianness into #ifdef __BIG_ENDIAN, and clean up a bit of style.
Quoted 3 lines · On Wed, 22 Jul 2009 00:01:59 +0200 Arnd Bergmann…
The powerpc
in_le32style functions are a completely different story, they are basically defined to operate only on on-chip components, while ioread32 and readl do work on PCI devices.
Quoted 6 lines · On Wed, 22 Jul 2009 23:20:58 +0200 Arnd Bergmann…
If it's a PCI/AGP/PCIe device, use
iowrite32be(), otherwise it may not work correctly on a pseries, celleb or qs20 machine.If it's connected over a different bus (IOIF on PS3),
out_be32would be more appropriate, but AFAICT, iowrite32be should work just as well.
--- drivers/gpu/drm/nouveau/nouveau_drv.h | 39 +++++++++++++++++------------- drivers/gpu/drm/nouveau/nouveau_state.c | 2 +- 2 files changed, 23 insertions(+), 18 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +22 -17
@@ -948,40 +948,45 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *, struct drm_file *);#define NVDEV ((struct drm_nouveau_private *)dev->dev_private) -#if defined(__powerpc__) -#define nv_out32 (map,reg,val) out_be32((void __iomem *)NVDEV->map->handle + (reg), (val)) -#define nv_out16 (map,reg,val) out_be16((void __iomem *)NVDEV->map->handle + (reg), (val)) -#define nv_in32 (map,reg) in_be32((void __iomem *)NVDEV->map->handle + (reg)) -#define nv_in16 (map,reg) in_be16((void __iomem *)NVDEV->map->handle + (reg)) +#ifdef __BIG_ENDIAN +#define nv_out32 (map, reg, val) \ + iowrite32be((val), (void __iomem *)NVDEV->map->handle + (reg)) +#define nv_out16 (map, reg, val) \ + iowrite16be((val), (void __iomem *)NVDEV->map->handle + (reg)) +#define nv_in32 (map, reg) \ + ioread32be((void __iomem *)NVDEV->map->handle + (reg)) +#define nv_in16 (map, reg) \ + ioread16be((void __iomem *)NVDEV->map->handle + (reg))#else -#define nv_out32 (map,reg,val) DRM_WRITE32(NVDEV->map, (reg), (val)) -#define nv_out16 (map,reg,val) DRM_WRITE16(NVDEV->map, (reg), (val)) -#define nv_in32 (map,reg) DRM_READ32(NVDEV->map, (reg)) -#define nv_in16 (map,reg) DRM_READ16(NVDEV->map, (reg)) +#define nv_out32 (map, reg, val) DRM_WRITE32(NVDEV->map, (reg), (val)) +#define nv_out16 (map, reg, val) DRM_WRITE16(NVDEV->map, (reg), (val)) +#define nv_in32 (map, reg) DRM_READ32(NVDEV->map, (reg)) +#define nv_in16 (map, reg) DRM_READ16(NVDEV->map, (reg))#endif /* channel control reg access */ -#if defined(__powerpc__) -#define nvchan_wr32 (reg,val) out_be32((void __iomem *)chan->user->handle + (reg), (val)) -#define nvchan_rd32 (reg) in_be32((void __iomem *)chan->user->handle + (reg)) +#ifdef __BIG_ENDIAN +#define nvchan_wr32 (reg, val) \ + iowrite32be((val), (void __iomem *)chan->user->handle + (reg)) +#define nvchan_rd32 (reg) ioread32be((void __iomem *)chan->user->handle + (reg))#else -#define nvchan_wr32 (reg,val) DRM_WRITE32(chan->user, (reg), (val)) +#define nvchan_wr32 (reg, val) DRM_WRITE32(chan->user, (reg), (val))#define nvchan_rd32 (reg) DRM_READ32(chan->user, (reg))#endif /* register access */ -#if defined(__powerpc__) +#ifdef __BIG_ENDIANstatic inline u32 nv_rd32 (struct drm_device *dev,unsigned reg) {struct drm_nouveau_private *dev_priv = dev->dev_private; -return in_be32 (dev_priv->mmio + reg); +return ioread32be (dev_priv->mmio + reg); }static inline void nv_wr32 (struct drm_device *dev,unsigned reg,u32 val) {struct drm_nouveau_private *dev_priv = dev->dev_private; -out_be32 (dev_priv->mmio + reg, val); +iowrite32be (val, dev_priv->mmio + reg); }#else static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg)
@@ -995,7 +1000,7 @@ static inline void nv_wr32(struct drm_device *dev, unsigned reg, u32 val)struct drm_nouveau_private *dev_priv = dev->dev_private; writel(val, dev_priv->mmio + reg); } -#endif /* not __powerpc__ */ +#endif /* not __BIG_ENDIAN */ static inline u8 nv_rd08 (struct drm_device *dev,unsigned reg) {
drivers/gpu/drm/nouveau/nouveau_state.c +1 -1
@@ -485,7 +485,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)NV_DEBUG (dev,"regs mapped ok at 0x%llx\n" , (unsigned long long )mmio_start_offs); -#if defined(__powerpc__) +#ifdef __BIG_ENDIAN/* Put the card in BE mode if it's not */ if (nv_rd32 (dev,NV03_PMC_BOOT_1 ))nv_wr32 (dev,NV03_PMC_BOOT_1 ,0x00000001 );
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/4 drm/nouveau: io{read,write}32_native API
Try to clean up the register accessor definitions by defining io{read,write}32_native API, which does not byteswap, and rewrite all accessors to use it.
As a consequence, readl/writel calls are changed to ioread32/iowrite32 also on x86. It adds a tiny overhead, since they are generic IO functions, but the overhead should be diminishing as compared to access over PCI bus.
All 16-bit accessors are removed as unused.
--- drivers/gpu/drm/nouveau/nouveau_drv.h | 58 +++++++++++---------------------- 1 files changed, 19 insertions(+), 39 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +19 -39
@@ -947,71 +947,51 @@ extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, void *,extern int nouveau_gem_ioctl_info (struct drm_device *,void *,struct drm_file *); -#define NVDEV ((struct drm_nouveau_private *)dev->dev_private) +#ifndef ioread32_native#ifdef __BIG_ENDIAN +#define ioread32_native ioread32be +#define iowrite32_native iowrite32be +#else /* def __BIG_ENDIAN */ +#define ioread32_native ioread32 +#define iowrite32_native iowrite32 +#endif /* def __BIG_ENDIAN else */ +#endif /* !ioread32_native */ + +#define NVDEV ((struct drm_nouveau_private *)dev->dev_private)#define nv_out32 (map, reg, val) \ - iowrite32be((val), (void __iomem *)NVDEV->map->handle + (reg)) -#define nv_out16 (map, reg, val) \ - iowrite16be((val), (void __iomem *)NVDEV->map->handle + (reg)) + iowrite32_native((val), (void __iomem *)NVDEV->map->handle + (reg))#define nv_in32 (map, reg) \ - ioread32be((void __iomem *)NVDEV->map->handle + (reg)) -#define nv_in16 (map, reg) \ - ioread16be((void __iomem *)NVDEV->map->handle + (reg)) -#else -#define nv_out32 (map, reg, val) DRM_WRITE32(NVDEV->map, (reg), (val)) -#define nv_out16 (map, reg, val) DRM_WRITE16(NVDEV->map, (reg), (val)) -#define nv_in32 (map, reg) DRM_READ32(NVDEV->map, (reg)) -#define nv_in16 (map, reg) DRM_READ16(NVDEV->map, (reg)) -#endif + ioread32_native((void __iomem *)NVDEV->map->handle + (reg))/* channel control reg access */ -#ifdef __BIG_ENDIAN#define nvchan_wr32 (reg, val) \ - iowrite32be((val), (void __iomem *)chan->user->handle + (reg)) -#define nvchan_rd32 (reg) ioread32be((void __iomem *)chan->user->handle + (reg)) -#else -#define nvchan_wr32 (reg, val) DRM_WRITE32(chan->user, (reg), (val)) -#define nvchan_rd32 (reg) DRM_READ32(chan->user, (reg)) -#endif - + iowrite32_native((val), (void __iomem *)chan->user->handle + (reg)) +#define nvchan_rd32 (reg) \ + ioread32_native((void __iomem *)chan->user->handle + (reg))/* register access */ -#ifdef __BIG_ENDIAN -static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg) -{ -struct drm_nouveau_private *dev_priv = dev->dev_private; -return ioread32be (dev_priv->mmio + reg); -} - -static inline void nv_wr32 (struct drm_device *dev,unsigned reg,u32 val) -{ -struct drm_nouveau_private *dev_priv = dev->dev_private; -iowrite32be (val, dev_priv->mmio + reg); -} -#else static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg) {struct drm_nouveau_private *dev_priv = dev->dev_private; -return readl (dev_priv->mmio + reg); +return ioread32_native (dev_priv->mmio + reg); }static inline void nv_wr32 (struct drm_device *dev,unsigned reg,u32 val) {struct drm_nouveau_private *dev_priv = dev->dev_private; -writel (val, dev_priv->mmio + reg); +iowrite32_native (val, dev_priv->mmio + reg); } -#endif /* not __BIG_ENDIAN */ static inline u8 nv_rd08 (struct drm_device *dev,unsigned reg) {struct drm_nouveau_private *dev_priv = dev->dev_private; -return readb (dev_priv->mmio + reg); +return ioread8 (dev_priv->mmio + reg); }static inline void nv_wr08 (struct drm_device *dev,unsigned reg,u8 val) {struct drm_nouveau_private *dev_priv = dev->dev_private; -writeb (val, dev_priv->mmio + reg); +iowrite8 (val, dev_priv->mmio + reg); }#define nv_wait (reg,mask,val) nouveau_wait_until(dev, 2000000000ULL, (reg), \
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 4/4 drm/nouveau: change FB map to simple ioremap
Remove the use of drm_local_map for the FB mapping and replace it with the equivalent ioremap.
Macros nv_[rw]f32() are changed into inline functions and the 'dev' argument is explicit.
Macros nv_[rw]v32() are removed as unused.
--- drivers/gpu/drm/nouveau/nouveau_drv.h | 17 ++++++++++++----- drivers/gpu/drm/nouveau/nouveau_hw.c | 16 ++++++++-------- drivers/gpu/drm/nouveau/nouveau_state.c | 12 +++++------- 3 files changed, 25 insertions(+), 20 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +12 -5
@@ -448,7 +448,7 @@ struct drm_nouveau_private {int flags;void __iomem *mmio; -struct drm_local_map *fb; +void __iomem *fb;struct drm_local_map *ramin;struct work_struct irq_work;
@@ -998,10 +998,17 @@ static inline void nv_wr08(struct drm_device *dev, unsigned reg, u8 val) (mask), (val))/* VRAM access */ -#define nv_rf32 (reg) nv_in32(fb, (reg)) -#define nv_wf32 (reg,val) nv_out32(fb, (reg), (val)) -#define nv_rv32 (reg) nv_rf32(reg) -#define nv_wv32 (reg,val) nv_wf32(reg, val) +static inline u32 nv_rf32 (struct drm_device *dev,unsigned reg) +{ +struct drm_nouveau_private *dev_priv = dev->dev_private; +return ioread32_native (dev_priv->fb + reg); +} + +static inline void nv_wf32 (struct drm_device *dev,unsigned reg,u32 val) +{ +struct drm_nouveau_private *dev_priv = dev->dev_private; +iowrite32_native (val, dev_priv->fb + reg); +}/* PRAMIN access */ #define nv_ri32 (reg) nv_in32(ramin, (reg))
drivers/gpu/drm/nouveau/nouveau_hw.c +8 -8
@@ -578,36 +578,36 @@ nouveau_hw_save_vga_fonts(struct drm_device *dev, bool save)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 (i *4 ); + dev_priv->saved_vga_font[0 ][i] =nv_rf32 (dev, i *4 );else -nv_wf32 (i *4 , dev_priv->saved_vga_font[0 ][i]); +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 (i *4 ); + dev_priv->saved_vga_font[1 ][i] =nv_rf32 (dev, i *4 );else -nv_wf32 (i *4 , dev_priv->saved_vga_font[1 ][i]); +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 (i *4 ); + dev_priv->saved_vga_font[2 ][i] =nv_rf32 (dev, i *4 );else -nv_wf32 (i *4 , dev_priv->saved_vga_font[2 ][i]); +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 (i *4 ); + dev_priv->saved_vga_font[3 ][i] =nv_rf32 (dev, i *4 );else -nv_wf32 (i *4 , dev_priv->saved_vga_font[3 ][i]); +nv_wf32 (dev, i *4 , dev_priv->saved_vga_font[3 ][i]);/* restore control regs */ NVWritePRMVIO (dev,0 ,NV_PRMVIO_MISC__WRITE , misc);
drivers/gpu/drm/nouveau/nouveau_state.c +5 -7
@@ -579,12 +579,10 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) }/* map first 64KiB of VRAM, holds VGA fonts etc */ - ret =drm_addmap (dev,drm_get_resource_start (dev,1 ),65536 , - _DRM_REGISTERS, _DRM_READ_ONLY | _DRM_DRIVER, - &dev_priv->fb); -if (ret) { -NV_ERROR (dev,"Failed to map FB BAR: %d\n" , ret); -return ret; + 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 ; }#if defined(__powerpc__)
@@ -656,7 +654,7 @@ int nouveau_unload(struct drm_device *dev)iounmap (dev_priv->mmio);drm_rmmap (dev, dev_priv->ramin); -drm_rmmap (dev, dev_priv->fb); +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]
Re: [PATCH 4/4] drm/nouveau: change FB map to simple ioremap
Quoted 2 lines · Pekka Paalanen
Remove the use of
drm_local_mapfor the FB mapping and replace it with the equivalent ioremap.
I don't think FBs are ioremapped normally with addmap, unless nouveau does something different here. Generally ioremapping the whole framebuffer is considered a bad idea as ioremap on 32-bit x86 is limited.
Dave.
Quoted 135 lines
Macros nv_[rw]f32() are changed into inline functions and the 'dev' argument is explicit.
Macros nv_[rw]v32() are removed as unused.
Signed-off-by Pekka Paalanen <[email protected]>---
drivers/gpu/drm/nouveau/nouveau_drv.h | 17 ++++++++++++-----drivers/gpu/drm/nouveau/nouveau_hw.c| 16 ++++++++--------drivers/gpu/drm/nouveau/nouveau_state.c| 12 +++++-------3 files changed, 25 insertions(+), 20 deletions(-)drivers/gpu/drm/nouveau/nouveau_drv.h +12
-5@@ -448,7 +448,7 @@ struct drm_nouveau_private { int flags; void __iomem *mmio; - struct drm_local_map *fb; + void __iomem *fb; struct drm_local_map *ramin; struct work_struct irq_work;@@ -998,10 +998,17 @@ static inline void nv_wr08(struct drm_device *dev, unsigned reg, u8 val) (mask), (val)) /* VRAM access */ -#define nv_rf32 (reg) nv_in32(fb, (reg)) -#define nv_wf32 (reg,val) nv_out32(fb, (reg), (val)) -#define nv_rv32 (reg) nv_rf32(reg) -#define nv_wv32 (reg,val) nv_wf32(reg, val) +static inline u32 nv_rf32 (struct drm_device *dev,unsigned reg) +{ + struct drm_nouveau_private *dev_priv = dev->dev_private; + return ioread32_native(dev_priv->fb + reg); +} + +static inline void nv_wf32 (struct drm_device *dev,unsigned reg,u32 val) +{ + struct drm_nouveau_private *dev_priv = dev->dev_private; + iowrite32_native(val, dev_priv->fb + reg); +} /* PRAMIN access */ #define nv_ri32(reg) nv_in32(ramin, (reg))drivers/gpu/drm/nouveau/nouveau_hw.c +1
-1@@ -578,36 +578,36 @@ nouveau_hw_save_vga_fonts(struct drm_device *dev, bool save) 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(i * 4); + dev_priv->saved_vga_font[0][i] = nv_rf32(dev, i * 4);else
-nv_wf32(i * 4, dev_priv->saved_vga_font[0][i]);
+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(i * 4);
+ dev_priv->saved_vga_font[1][i] =nv_rf32(dev, i * 4); else
-nv_wf32(i * 4, dev_priv->saved_vga_font[1][i]);
+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(i * 4);
+ dev_priv->saved_vga_font[2][i] =nv_rf32(dev, i * 4); else
-nv_wf32(i * 4, dev_priv->saved_vga_font[2][i]);
+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(i * 4);
+ dev_priv->saved_vga_font[3][i] =nv_rf32(dev, i * 4); else
-nv_wf32(i * 4, dev_priv->saved_vga_font[3][i]);
+nv_wf32(dev, i * 4, dev_priv->saved_vga_font[3][i]);/* restore control regs */
NVWritePRMVIO(dev, 0, NV_PRMVIO_MISC__WRITE, misc);drivers/gpu/drm/nouveau/nouveau_state.c +5
-8@@ -579,12 +579,10 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) } /* map first 64KiB of VRAM, holds VGA fonts etc */ - ret = drm_addmap(dev, drm_get_resource_start(dev, 1), 65536, - _DRM_REGISTERS, _DRM_READ_ONLY | _DRM_DRIVER, - &dev_priv->fb); - if (ret) { - NV_ERROR(dev, "Failed to map FB BAR: %d\n", ret); - return ret; + 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; } #if defined(__powerpc__)@@ -656,7 +654,7 @@ int nouveau_unload(struct drm_device *dev) iounmap(dev_priv->mmio); drm_rmmap(dev, dev_priv->ramin); - drm_rmmap(dev, dev_priv->fb); + iounmap(dev_priv->fb); kfree(dev_priv); dev->dev_private = NULL; --1.6.3.3
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 21d7e9970907260403k68294124xcd10802e6d7cd220-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 4/4] drm/nouveau: change FB map to simple ioremap
Quoted 8 lines · Dave Airlie
Quoted 2 lines · Pekka Paalanen
Remove the use of
drm_local_mapfor the FB mapping and replace it with the equivalent ioremap.I don't think FBs are ioremapped normally with addmap, unless nouveau does something different here. Generally ioremapping the whole framebuffer is considered a bad idea as ioremap on 32-bit x86 is limited.
/me reads patch properly ;-)
Notice DRM_REGISTERS. oops. looks fine then.
Dave.
A message that is not in the archive (sent off-list or not yet received): 21d7e9970907260408w17d05e43p4954b8553f574dee-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 4/4] drm/nouveau: change FB map to simple ioremap
Quoted 5 lines · On Sun, 26 Jul 2009 21:08:09 +1000 Dave Airlie…
Quoted 4 lines · Dave Airlie
Quoted 2 lines · Pekka Paalanen
Remove the use of
drm_local_mapfor the FB mapping and replace it with the equivalent ioremap.
Quoted 8 lines
Quoted 4 lines
I don't think FBs are ioremapped normally with addmap, unless nouveau does something different here. Generally ioremapping the whole framebuffer is considered a bad idea as ioremap on 32-bit x86 is limited.
/me reads patch properly ;-)
Notice
DRM_REGISTERS. oops. looks fine then.
Yeah, the name '->fb' could be better, but at least there's a comment in the code that it's not really the whole FB :-P
Thanks for the review.
Signature · 2 lines
Pekka Paalanen http://www.iki.fi/pq/