2010-03-01 00:18:39 +00:00
|
|
|
#include "drmP.h"
|
|
|
|
#include "drm.h"
|
|
|
|
#include "nouveau_drv.h"
|
|
|
|
#include "nouveau_drm.h"
|
|
|
|
|
2010-11-15 02:50:50 +00:00
|
|
|
struct nv50_fb_priv {
|
|
|
|
struct page *r100c08_page;
|
|
|
|
dma_addr_t r100c08;
|
|
|
|
};
|
|
|
|
|
2011-02-13 23:57:35 +00:00
|
|
|
static void
|
|
|
|
nv50_fb_destroy(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
|
|
|
|
struct nv50_fb_priv *priv = pfb->priv;
|
|
|
|
|
|
|
|
if (drm_mm_initialized(&pfb->tag_heap))
|
|
|
|
drm_mm_takedown(&pfb->tag_heap);
|
|
|
|
|
|
|
|
if (priv->r100c08_page) {
|
|
|
|
pci_unmap_page(dev->pdev, priv->r100c08, PAGE_SIZE,
|
|
|
|
PCI_DMA_BIDIRECTIONAL);
|
|
|
|
__free_page(priv->r100c08_page);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(priv);
|
|
|
|
pfb->priv = NULL;
|
|
|
|
}
|
|
|
|
|
2010-11-15 02:50:50 +00:00
|
|
|
static int
|
|
|
|
nv50_fb_create(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
2011-02-13 23:57:35 +00:00
|
|
|
struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
|
2010-11-15 02:50:50 +00:00
|
|
|
struct nv50_fb_priv *priv;
|
2011-02-13 23:57:35 +00:00
|
|
|
u32 tagmem;
|
|
|
|
int ret;
|
2010-11-15 02:50:50 +00:00
|
|
|
|
|
|
|
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
|
|
|
if (!priv)
|
|
|
|
return -ENOMEM;
|
2011-02-13 23:57:35 +00:00
|
|
|
pfb->priv = priv;
|
2010-11-15 02:50:50 +00:00
|
|
|
|
|
|
|
priv->r100c08_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
|
|
|
if (!priv->r100c08_page) {
|
2011-02-13 23:57:35 +00:00
|
|
|
nv50_fb_destroy(dev);
|
2010-11-15 02:50:50 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->r100c08 = pci_map_page(dev->pdev, priv->r100c08_page, 0,
|
|
|
|
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
|
|
|
|
if (pci_dma_mapping_error(dev->pdev, priv->r100c08)) {
|
2011-02-13 23:57:35 +00:00
|
|
|
nv50_fb_destroy(dev);
|
2010-11-15 02:50:50 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2011-02-13 23:57:35 +00:00
|
|
|
tagmem = nv_rd32(dev, 0x100320);
|
|
|
|
NV_DEBUG(dev, "%d tags available\n", tagmem);
|
|
|
|
ret = drm_mm_init(&pfb->tag_heap, 0, tagmem);
|
|
|
|
if (ret) {
|
|
|
|
nv50_fb_destroy(dev);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-15 02:50:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-01 00:18:39 +00:00
|
|
|
int
|
|
|
|
nv50_fb_init(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
2010-11-15 02:50:50 +00:00
|
|
|
struct nv50_fb_priv *priv;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!dev_priv->engine.fb.priv) {
|
|
|
|
ret = nv50_fb_create(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
priv = dev_priv->engine.fb.priv;
|
2010-03-01 00:18:39 +00:00
|
|
|
|
2010-06-07 03:59:40 +00:00
|
|
|
/* Not a clue what this is exactly. Without pointing it at a
|
|
|
|
* scratch page, VRAM->GART blits with M2MF (as in DDX DFS)
|
|
|
|
* cause IOMMU "read from address 0" errors (rh#561267)
|
|
|
|
*/
|
2010-11-15 02:50:50 +00:00
|
|
|
nv_wr32(dev, 0x100c08, priv->r100c08 >> 8);
|
2010-06-07 03:59:40 +00:00
|
|
|
|
|
|
|
/* This is needed to get meaningful information from 100c90
|
|
|
|
* on traps. No idea what these values mean exactly. */
|
2010-03-01 00:18:39 +00:00
|
|
|
switch (dev_priv->chipset) {
|
|
|
|
case 0x50:
|
2010-11-15 02:52:23 +00:00
|
|
|
nv_wr32(dev, 0x100c90, 0x000707ff);
|
2010-03-01 00:18:39 +00:00
|
|
|
break;
|
2010-09-13 01:12:50 +00:00
|
|
|
case 0xa3:
|
2010-03-01 00:18:39 +00:00
|
|
|
case 0xa5:
|
|
|
|
case 0xa8:
|
2010-11-15 02:52:23 +00:00
|
|
|
nv_wr32(dev, 0x100c90, 0x000d0fff);
|
|
|
|
break;
|
|
|
|
case 0xaf:
|
|
|
|
nv_wr32(dev, 0x100c90, 0x089d1fff);
|
2010-03-01 00:18:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-11-15 02:52:23 +00:00
|
|
|
nv_wr32(dev, 0x100c90, 0x001d07ff);
|
2010-03-01 00:18:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nv50_fb_takedown(struct drm_device *dev)
|
|
|
|
{
|
2011-02-13 23:57:35 +00:00
|
|
|
nv50_fb_destroy(dev);
|
2010-03-01 00:18:39 +00:00
|
|
|
}
|
2010-09-03 05:46:58 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nv50_fb_vm_trap(struct drm_device *dev, int display, const char *name)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
2010-10-06 06:16:59 +00:00
|
|
|
unsigned long flags;
|
2010-09-03 05:46:58 +00:00
|
|
|
u32 trap[6], idx, chinst;
|
|
|
|
int i, ch;
|
|
|
|
|
|
|
|
idx = nv_rd32(dev, 0x100c90);
|
|
|
|
if (!(idx & 0x80000000))
|
|
|
|
return;
|
|
|
|
idx &= 0x00ffffff;
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
nv_wr32(dev, 0x100c90, idx | i << 24);
|
|
|
|
trap[i] = nv_rd32(dev, 0x100c94);
|
|
|
|
}
|
|
|
|
nv_wr32(dev, 0x100c90, idx | 0x80000000);
|
|
|
|
|
|
|
|
if (!display)
|
|
|
|
return;
|
|
|
|
|
|
|
|
chinst = (trap[2] << 16) | trap[1];
|
2010-10-06 06:16:59 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&dev_priv->channels.lock, flags);
|
2010-09-03 05:46:58 +00:00
|
|
|
for (ch = 0; ch < dev_priv->engine.fifo.channels; ch++) {
|
2010-10-06 06:16:59 +00:00
|
|
|
struct nouveau_channel *chan = dev_priv->channels.ptr[ch];
|
2010-09-03 05:46:58 +00:00
|
|
|
|
|
|
|
if (!chan || !chan->ramin)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (chinst == chan->ramin->vinst >> 12)
|
|
|
|
break;
|
|
|
|
}
|
2010-10-06 06:16:59 +00:00
|
|
|
spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
|
2010-09-03 05:46:58 +00:00
|
|
|
|
|
|
|
NV_INFO(dev, "%s - VM: Trapped %s at %02x%04x%04x status %08x "
|
|
|
|
"channel %d (0x%08x)\n",
|
|
|
|
name, (trap[5] & 0x100 ? "read" : "write"),
|
|
|
|
trap[5] & 0xff, trap[4] & 0xffff, trap[3] & 0xffff,
|
|
|
|
trap[0], ch, chinst);
|
|
|
|
}
|