From dd1f33f83cbbb9917e13f194fadda4f7066ea98a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 May 2008 22:35:32 +1000 Subject: ati_pcigart: fill out 40-bit gart table support properly Thanks to Alex for supplying this info. --- linux-core/ati_pcigart.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'linux-core/ati_pcigart.c') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index beaa4424..34081d4f 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -34,6 +34,8 @@ #include "drmP.h" # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ +# define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1)) + static int drm_ati_alloc_pcigart_table(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) { @@ -148,18 +150,23 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga bus_address = 0; goto done; } - page_base = (u32) entry->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { switch(gart_info->gart_reg_if) { case DRM_ATI_GART_IGP: + page_base = (u32) entry->busaddr[i] & ATI_PCIGART_PAGE_MASK; + page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 4; *pci_gart = cpu_to_le32((page_base) | 0xc); break; case DRM_ATI_GART_PCIE: + page_base = (u32)(entry->busaddr[i] & ATI_PCIGART_PAGE_MASK); + page_base >>= 8; + page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 24; *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); break; default: case DRM_ATI_GART_PCI: + page_base = (u32) entry->busaddr[i]; *pci_gart = cpu_to_le32(page_base); break; } -- cgit v1.2.3 From bc0836e12a9790f1cc83f8bc29bc05043c4bc840 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 May 2008 22:42:21 +1000 Subject: ati_pcigart: fixup properly this version might even work --- linux-core/ati_pcigart.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'linux-core/ati_pcigart.c') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index 34081d4f..f7752b5e 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -36,6 +36,9 @@ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ # define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1)) +#define ATI_PCIE_WRITE 0x4 +#define ATI_PCIE_READ 0x8 + static int drm_ati_alloc_pcigart_table(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) { @@ -105,6 +108,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga dma_addr_t bus_address = 0; int i, j, ret = 0; int max_pages; + dma_addr_t entry_addr; if (!entry) { DRM_ERROR("no scatter/gather memory!\n"); @@ -151,27 +155,26 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga goto done; } + entry_addr = entry->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { + page_base = (u32) entry_addr & ATI_PCIGART_PAGE_MASK; switch(gart_info->gart_reg_if) { case DRM_ATI_GART_IGP: - page_base = (u32) entry->busaddr[i] & ATI_PCIGART_PAGE_MASK; - page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 4; - *pci_gart = cpu_to_le32((page_base) | 0xc); + page_base |= (upper_32_bits(entry_addr) & 0xff) << 4; + page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE; break; case DRM_ATI_GART_PCIE: - page_base = (u32)(entry->busaddr[i] & ATI_PCIGART_PAGE_MASK); page_base >>= 8; - page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 24; - *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); + page_base |= (upper_32_bits(entry_addr) & 0xff) << 24; + page_base |= 0xc; break; default: case DRM_ATI_GART_PCI: - page_base = (u32) entry->busaddr[i]; - *pci_gart = cpu_to_le32(page_base); break; } + *pci_gart = cpu_to_le32(page_base); pci_gart++; - page_base += ATI_PCIGART_PAGE_SIZE; + entry_addr += ATI_PCIGART_PAGE_SIZE; } } -- cgit v1.2.3 From 2712cdeec319d73187a6cccb06522a4125eef619 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 May 2008 22:43:28 +1000 Subject: Revert "ati_pcigart: fixup properly this version might even work" This reverts commit bc0836e12a9790f1cc83f8bc29bc05043c4bc840. tree has some kref hacks in it - oops --- linux-core/ati_pcigart.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'linux-core/ati_pcigart.c') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index f7752b5e..34081d4f 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -36,9 +36,6 @@ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ # define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1)) -#define ATI_PCIE_WRITE 0x4 -#define ATI_PCIE_READ 0x8 - static int drm_ati_alloc_pcigart_table(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) { @@ -108,7 +105,6 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga dma_addr_t bus_address = 0; int i, j, ret = 0; int max_pages; - dma_addr_t entry_addr; if (!entry) { DRM_ERROR("no scatter/gather memory!\n"); @@ -155,26 +151,27 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga goto done; } - entry_addr = entry->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { - page_base = (u32) entry_addr & ATI_PCIGART_PAGE_MASK; switch(gart_info->gart_reg_if) { case DRM_ATI_GART_IGP: - page_base |= (upper_32_bits(entry_addr) & 0xff) << 4; - page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE; + page_base = (u32) entry->busaddr[i] & ATI_PCIGART_PAGE_MASK; + page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 4; + *pci_gart = cpu_to_le32((page_base) | 0xc); break; case DRM_ATI_GART_PCIE: + page_base = (u32)(entry->busaddr[i] & ATI_PCIGART_PAGE_MASK); page_base >>= 8; - page_base |= (upper_32_bits(entry_addr) & 0xff) << 24; - page_base |= 0xc; + page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 24; + *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); break; default: case DRM_ATI_GART_PCI: + page_base = (u32) entry->busaddr[i]; + *pci_gart = cpu_to_le32(page_base); break; } - *pci_gart = cpu_to_le32(page_base); pci_gart++; - entry_addr += ATI_PCIGART_PAGE_SIZE; + page_base += ATI_PCIGART_PAGE_SIZE; } } -- cgit v1.2.3 From 4c6ec02eb8b1a5723f1a00dc420740d440a9ee0d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 May 2008 22:44:22 +1000 Subject: ati_pcigart: stop working in the evenings you mess up too often --- linux-core/ati_pcigart.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'linux-core/ati_pcigart.c') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index 34081d4f..f7752b5e 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -36,6 +36,9 @@ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ # define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1)) +#define ATI_PCIE_WRITE 0x4 +#define ATI_PCIE_READ 0x8 + static int drm_ati_alloc_pcigart_table(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) { @@ -105,6 +108,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga dma_addr_t bus_address = 0; int i, j, ret = 0; int max_pages; + dma_addr_t entry_addr; if (!entry) { DRM_ERROR("no scatter/gather memory!\n"); @@ -151,27 +155,26 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga goto done; } + entry_addr = entry->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { + page_base = (u32) entry_addr & ATI_PCIGART_PAGE_MASK; switch(gart_info->gart_reg_if) { case DRM_ATI_GART_IGP: - page_base = (u32) entry->busaddr[i] & ATI_PCIGART_PAGE_MASK; - page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 4; - *pci_gart = cpu_to_le32((page_base) | 0xc); + page_base |= (upper_32_bits(entry_addr) & 0xff) << 4; + page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE; break; case DRM_ATI_GART_PCIE: - page_base = (u32)(entry->busaddr[i] & ATI_PCIGART_PAGE_MASK); page_base >>= 8; - page_base |= (upper_32_bits(entry->busaddr[i]) & 0xff) << 24; - *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); + page_base |= (upper_32_bits(entry_addr) & 0xff) << 24; + page_base |= 0xc; break; default: case DRM_ATI_GART_PCI: - page_base = (u32) entry->busaddr[i]; - *pci_gart = cpu_to_le32(page_base); break; } + *pci_gart = cpu_to_le32(page_base); pci_gart++; - page_base += ATI_PCIGART_PAGE_SIZE; + entry_addr += ATI_PCIGART_PAGE_SIZE; } } -- cgit v1.2.3 From a09c0bbe11004a020d0fac47f7517db55fb91754 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 May 2008 22:48:12 +1000 Subject: ati_pcigart: oops wrong way around not that it actually mattered --- linux-core/ati_pcigart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/ati_pcigart.c') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index f7752b5e..09251ac3 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -161,12 +161,12 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga switch(gart_info->gart_reg_if) { case DRM_ATI_GART_IGP: page_base |= (upper_32_bits(entry_addr) & 0xff) << 4; - page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE; + page_base |= 0xc; break; case DRM_ATI_GART_PCIE: page_base >>= 8; page_base |= (upper_32_bits(entry_addr) & 0xff) << 24; - page_base |= 0xc; + page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE; break; default: case DRM_ATI_GART_PCI: -- cgit v1.2.3