From dc592c8b7bc12d16c658648f124792ac4d2882b9 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Sat, 29 Sep 2007 23:06:29 +0300 Subject: nouveau: Make nv20 use the nv30 PGRAPH ctx functions. --- shared-core/nouveau_state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index e73b4878..f8dd3ad5 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -166,10 +166,10 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) engine->fb.takedown = nv10_fb_takedown; engine->graph.init = nv20_graph_init; engine->graph.takedown = nv20_graph_takedown; - engine->graph.create_context = nv20_graph_create_context; - engine->graph.destroy_context = nv20_graph_destroy_context; - engine->graph.load_context = nv20_graph_load_context; - engine->graph.save_context = nv20_graph_save_context; + engine->graph.create_context = nv30_graph_create_context; + engine->graph.destroy_context = nv30_graph_destroy_context; + engine->graph.load_context = nv30_graph_load_context; + engine->graph.save_context = nv30_graph_save_context; engine->fifo.init = nouveau_fifo_init; engine->fifo.takedown = nouveau_stub_takedown; engine->fifo.create_context = nv10_fifo_create_context; -- cgit v1.2.3 From 205403aea8213ffc0e36f4103d78d62bf1584a69 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Sun, 30 Sep 2007 21:10:06 +0300 Subject: nouveau: nv30 graph function renames, removed nv20_graph.c All nv30 functions in nv30_graph.c that can be used on nv20 are renamed as accordingly. nv20 specific parts from nv20_graph.c are moved into nv30_graph.c. --- shared-core/nouveau_state.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index f8dd3ad5..cba12b57 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -166,10 +166,10 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) engine->fb.takedown = nv10_fb_takedown; engine->graph.init = nv20_graph_init; engine->graph.takedown = nv20_graph_takedown; - engine->graph.create_context = nv30_graph_create_context; - engine->graph.destroy_context = nv30_graph_destroy_context; - engine->graph.load_context = nv30_graph_load_context; - engine->graph.save_context = nv30_graph_save_context; + engine->graph.create_context = nv20_graph_create_context; + engine->graph.destroy_context = nv20_graph_destroy_context; + engine->graph.load_context = nv20_graph_load_context; + engine->graph.save_context = nv20_graph_save_context; engine->fifo.init = nouveau_fifo_init; engine->fifo.takedown = nouveau_stub_takedown; engine->fifo.create_context = nv10_fifo_create_context; @@ -192,11 +192,11 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) engine->fb.init = nv10_fb_init; engine->fb.takedown = nv10_fb_takedown; engine->graph.init = nv30_graph_init; - engine->graph.takedown = nv30_graph_takedown; - engine->graph.create_context = nv30_graph_create_context; - engine->graph.destroy_context = nv30_graph_destroy_context; - engine->graph.load_context = nv30_graph_load_context; - engine->graph.save_context = nv30_graph_save_context; + engine->graph.takedown = nv20_graph_takedown; + engine->graph.create_context = nv20_graph_create_context; + engine->graph.destroy_context = nv20_graph_destroy_context; + engine->graph.load_context = nv20_graph_load_context; + engine->graph.save_context = nv20_graph_save_context; engine->fifo.init = nouveau_fifo_init; engine->fifo.takedown = nouveau_stub_takedown; engine->fifo.create_context = nv10_fifo_create_context; -- cgit v1.2.3 From 69fcfb413e72ad2204d306f20af6547819e040da Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Mon, 1 Oct 2007 22:21:23 +0200 Subject: nouveau: Fix dereferencing a NULL pointer when erroring out during initialization. --- shared-core/nouveau_state.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index cba12b57..cb19c880 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -423,12 +423,15 @@ void nouveau_lastclose(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; - nouveau_card_takedown(dev); - - if(dev_priv->fb_mtrr>0) - { - drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC); - dev_priv->fb_mtrr=0; + /* In the case of an error dev_priv may not be be allocated yet */ + if (dev_priv && dev_priv->card_type) { + nouveau_card_takedown(dev); + + if(dev_priv->fb_mtrr>0) + { + drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC); + dev_priv->fb_mtrr=0; + } } } -- cgit v1.2.3 From b510517d59efcb45cc7079743be967bee122b251 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 4 Oct 2007 09:31:46 +0200 Subject: nouveau: Switch over to using PMC_BOOT_0 for card detection. --- shared-core/nouveau_state.c | 74 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 6 deletions(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index cb19c880..a163ae63 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -403,19 +403,81 @@ int nouveau_firstopen(struct drm_device *dev) int nouveau_load(struct drm_device *dev, unsigned long flags) { struct drm_nouveau_private *dev_priv; - - if (flags==NV_UNKNOWN) - return -EINVAL; + void __iomem *regs; + uint32_t reg0; + char architecture = 0; dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - if (!dev_priv) + if (!dev_priv) return -ENOMEM; - dev_priv->card_type=flags&NOUVEAU_FAMILY; - dev_priv->flags=flags&NOUVEAU_FLAGS; + dev_priv->flags = flags & NOUVEAU_FLAGS; dev_priv->init_state = NOUVEAU_CARD_INIT_DOWN; + DRM_DEBUG("vendor: 0x%X device: 0x%X class: 0x%X\n", dev->pci_vendor, dev->pci_device, dev->pdev->class); + + /* Time to determine the card architecture */ + regs = ioremap_nocache(pci_resource_start(dev->pdev, 0), 0x4); + if (!regs) { + DRM_ERROR("Could not ioremap to determine register\n"); + return -ENOMEM; + } + reg0 = readl(regs); + + /* We're dealing with >=NV10 */ + if ((reg0 & 0x0f000000) > 0 ) { + /* Bit 27-20 contain the architecture in hex */ + architecture = (reg0 & 0xff00000) >> 20; + /* NV04 or NV05 */ + } else if ((reg0 & 0xff00fff0) == 0x20004000) { + architecture = 0x04; + } + + iounmap(regs); + + if (architecture >= 0x50) { + dev_priv->card_type = NV_50; + } else if (architecture >= 0x44) { + dev_priv->card_type = NV_44; + } else if (architecture >= 0x40) { + dev_priv->card_type = NV_40; + } else if (architecture >= 0x34) { + dev_priv->card_type = NV_34; + } else if (architecture >= 0x30) { + dev_priv->card_type = NV_30; + } else if (architecture >= 0x25) { + dev_priv->card_type = NV_25; + } else if (architecture >= 0x20) { + dev_priv->card_type = NV_20; + } else if (architecture >= 0x17) { + dev_priv->card_type = NV_17; + } else if (architecture >= 0x15) { + dev_priv->card_type = NV_15; + } else if (architecture >= 0x11) { + dev_priv->card_type = NV_11; + } else if (architecture >= 0x10) { + dev_priv->card_type = NV_10; + } else if (architecture >= 0x04) { + dev_priv->card_type = NV_04; + } else { + dev_priv->card_type = NV_UNKNOWN; + } + + DRM_INFO("Detected an NV%d generation card\n", dev_priv->card_type); + + if (dev_priv->card_type == NV_UNKNOWN) { + return -EINVAL; + } + + /* Special flags */ + if (dev->pci_device == 0x01a0) { + dev_priv->flags |= NV_NFORCE; + } else if (dev->pci_device == 0x01f0) { + dev_priv->flags |= NV_NFORCE2; + } + dev->dev_private = (void *)dev_priv; + return 0; } -- cgit v1.2.3 From d351601899e5814d809b8e86ab6f0d6e7676f585 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 4 Oct 2007 09:46:16 +0200 Subject: nouveau: Remove excess device classes. --- shared-core/nouveau_state.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index a163ae63..dc075d0c 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -441,18 +441,12 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev_priv->card_type = NV_44; } else if (architecture >= 0x40) { dev_priv->card_type = NV_40; - } else if (architecture >= 0x34) { - dev_priv->card_type = NV_34; } else if (architecture >= 0x30) { dev_priv->card_type = NV_30; - } else if (architecture >= 0x25) { - dev_priv->card_type = NV_25; } else if (architecture >= 0x20) { dev_priv->card_type = NV_20; } else if (architecture >= 0x17) { dev_priv->card_type = NV_17; - } else if (architecture >= 0x15) { - dev_priv->card_type = NV_15; } else if (architecture >= 0x11) { dev_priv->card_type = NV_11; } else if (architecture >= 0x10) { -- cgit v1.2.3 From 20928a2f2b3f1fa15c46edcf7e20f97566664ce8 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Sun, 7 Oct 2007 19:01:56 +0200 Subject: nouveau: A char is signed, so it may overflow for >NV50. --- shared-core/nouveau_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index dc075d0c..fd80e1e7 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -405,7 +405,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) struct drm_nouveau_private *dev_priv; void __iomem *regs; uint32_t reg0; - char architecture = 0; + uint8_t architecture = 0; dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); if (!dev_priv) -- cgit v1.2.3 From 9b294bbe0ec79177298ea32746fbed03fcf62055 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Wed, 10 Oct 2007 01:12:20 +0200 Subject: nouveau: try to fix big endian. --- shared-core/nouveau_state.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index fd80e1e7..eec88fe4 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -283,6 +283,10 @@ nouveau_card_init(struct drm_device *dev) ret = nouveau_init_card_mappings(dev); if (ret) return ret; + /* Put the card in BE mode if it's not */ + if (NV_READ(NV03_PMC_BOOT_1)) + NV_WRITE(NV03_PMC_BOOT_1,0x01000001); + /* Determine exact chipset we're running on */ if (dev_priv->card_type < NV_10) dev_priv->chipset = dev_priv->card_type; @@ -404,7 +408,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) { struct drm_nouveau_private *dev_priv; void __iomem *regs; - uint32_t reg0; + uint32_t reg0,reg1; uint8_t architecture = 0; dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); @@ -422,7 +426,11 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) DRM_ERROR("Could not ioremap to determine register\n"); return -ENOMEM; } - reg0 = readl(regs); + + reg0 = readl(regs+NV03_PMC_BOOT_0); + reg1 = readl(regs+NV03_PMC_BOOT_1); + if (reg1) + reg0=___swab32(reg0); /* We're dealing with >=NV10 */ if ((reg0 & 0x0f000000) > 0 ) { @@ -457,7 +465,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev_priv->card_type = NV_UNKNOWN; } - DRM_INFO("Detected an NV%d generation card\n", dev_priv->card_type); + DRM_INFO("Detected an NV%d generation card (0x%08x)\n", dev_priv->card_type,reg0); if (dev_priv->card_type == NV_UNKNOWN) { return -EINVAL; -- cgit v1.2.3 From d912709a63c59d0b3e48458bac41fb76ea279214 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Wed, 10 Oct 2007 16:41:21 +0200 Subject: nouveau: PMC_BOOT_1 was not mapped. --- shared-core/nouveau_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index eec88fe4..3ce9247f 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -421,7 +421,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) DRM_DEBUG("vendor: 0x%X device: 0x%X class: 0x%X\n", dev->pci_vendor, dev->pci_device, dev->pdev->class); /* Time to determine the card architecture */ - regs = ioremap_nocache(pci_resource_start(dev->pdev, 0), 0x4); + regs = ioremap_nocache(pci_resource_start(dev->pdev, 0), 0x8); if (!regs) { DRM_ERROR("Could not ioremap to determine register\n"); return -ENOMEM; -- cgit v1.2.3 From 30353c8efcc026ee8940f3eadab084c42a3acd4e Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Sun, 14 Oct 2007 23:07:30 +0200 Subject: nouveau: PPC fixes. These regs are very touchy. --- shared-core/nouveau_state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'shared-core/nouveau_state.c') diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index 3ce9247f..add2d598 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -285,7 +285,9 @@ nouveau_card_init(struct drm_device *dev) /* Put the card in BE mode if it's not */ if (NV_READ(NV03_PMC_BOOT_1)) - NV_WRITE(NV03_PMC_BOOT_1,0x01000001); + NV_WRITE(NV03_PMC_BOOT_1,0x00000001); + + DRM_MEMORYBARRIER(); /* Determine exact chipset we're running on */ if (dev_priv->card_type < NV_10) -- cgit v1.2.3