Commit f26c473c authored by Dave Airlie's avatar Dave Airlie Committed by Dave Airlie
Browse files

drm: update PCIGART support from CVS



In order to work on FreeBSD the gart needed to use a local mapping
This patch moves the mainline to the new code and aligns some comment
changes

From: Eric Anholt <anholt@freebsd.org>
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent 0a406877
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@
# define ATI_MAX_PCIGART_PAGES		8192	/**< 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE		4096	/**< PCI GART page size */

static unsigned long drm_ati_alloc_pcigart_table(void)
static void *drm_ati_alloc_pcigart_table(void)
{
	unsigned long address;
	struct page *page;
@@ -72,27 +72,26 @@ static unsigned long drm_ati_alloc_pcigart_table(void)
	}

	DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
	return address;
	return (void *)address;
}

static void drm_ati_free_pcigart_table(unsigned long address)
static void drm_ati_free_pcigart_table(void *address)
{
	struct page *page;
	int i;
	DRM_DEBUG("%s\n", __FUNCTION__);

	page = virt_to_page(address);
	page = virt_to_page((unsigned long)address);

	for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) {
		__put_page(page);
		ClearPageReserved(page);
	}

	free_pages(address, ATI_PCIGART_TABLE_ORDER);
	free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
}

int drm_ati_pcigart_cleanup(drm_device_t * dev,
			    drm_ati_pcigart_info * gart_info)
int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
{
	drm_sg_mem_t *entry = dev->sg;
	unsigned long pages;
@@ -139,7 +138,7 @@ EXPORT_SYMBOL(drm_ati_pcigart_cleanup);
int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
{
	drm_sg_mem_t *entry = dev->sg;
	unsigned long address = 0;
	void *address = NULL;
	unsigned long pages;
	u32 *pci_gart, page_base, bus_address = 0;
	int i, j, ret = 0;
@@ -163,7 +162,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info)
			goto done;
		}

		bus_address = pci_map_single(dev->pdev, (void *)address,
		bus_address = pci_map_single(dev->pdev, address,
					     ATI_PCIGART_TABLE_PAGES *
					     PAGE_SIZE, PCI_DMA_TODEVICE);
		if (bus_address == 0) {
@@ -176,7 +175,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info)
		address = gart_info->addr;
		bus_address = gart_info->bus_addr;
		DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n",
			  bus_address, address);
			  bus_address, (unsigned long)address);
	}

	pci_gart = (u32 *) address;
@@ -195,7 +194,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info)
		if (entry->busaddr[i] == 0) {
			DRM_ERROR("unable to map PCIGART pages!\n");
			drm_ati_pcigart_cleanup(dev, gart_info);
			address = 0;
			address = NULL;
			bus_address = 0;
			goto done;
		}
+2 −1
Original line number Diff line number Diff line
@@ -522,8 +522,9 @@ typedef struct drm_vbl_sig {
typedef struct ati_pcigart_info {
	int gart_table_location;
	int is_pcie;
	unsigned long addr;
	void *addr;
	dma_addr_t bus_addr;
	drm_local_map_t mapping;
} drm_ati_pcigart_info;

/**
+9 −6
Original line number Diff line number Diff line
/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*- 
 * Created: Wed Apr  5 19:24:19 2000 by kevin@precisioninsight.com
 *
 */
/*
 * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
 * All Rights Reserved.
@@ -559,7 +560,8 @@ static int r128_do_init_cce(drm_device_t * dev, drm_r128_init_t * init)
	if (dev_priv->is_pci) {
#endif
		dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN;
		dev_priv->gart_info.addr = dev_priv->gart_info.bus_addr = 0;
		dev_priv->gart_info.addr = NULL;
		dev_priv->gart_info.bus_addr = 0;
		dev_priv->gart_info.is_pcie = 0;
		if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) {
			DRM_ERROR("failed to init PCI GART!\n");
@@ -601,15 +603,16 @@ int r128_do_cleanup_cce(drm_device_t * dev)
				drm_core_ioremapfree(dev_priv->cce_ring, dev);
			if (dev_priv->ring_rptr != NULL)
				drm_core_ioremapfree(dev_priv->ring_rptr, dev);
			if (dev->agp_buffer_map != NULL)
			if (dev->agp_buffer_map != NULL) {
				drm_core_ioremapfree(dev->agp_buffer_map, dev);
				dev->agp_buffer_map = NULL;
			}
		} else
#endif
		{
			if (dev_priv->gart_info.bus_addr)
				if (!drm_ati_pcigart_cleanup(dev,
							     &dev_priv->
							     gart_info))
							&dev_priv->gart_info))
					DRM_ERROR
					    ("failed to cleanup PCI GART!\n");
		}
+2 −2
Original line number Diff line number Diff line
/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
 * Created: Wed Apr  5 19:24:19 2000 by kevin@precisioninsight.com
 *
 * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
 */
/* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
 * All rights reserved.
 *
+2 −2
Original line number Diff line number Diff line
/* r128_drv.h -- Private header for r128 driver -*- linux-c -*-
 * Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com
 *
 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
 */
/* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
 * All rights reserved.
 *
Loading