All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Glisse <jglisse@redhat.com>
To: airlied@gmail.com
Cc: Jerome Glisse <jglisse@redhat.com>, dri-devel@lists.sf.net
Subject: [PATCH 12/13] drm/ttm: remove io_ field from TTM V5
Date: Wed,  7 Apr 2010 12:21:30 +0200	[thread overview]
Message-ID: <1270635691-2933-13-git-send-email-jglisse@redhat.com> (raw)
In-Reply-To: <1270635691-2933-12-git-send-email-jglisse@redhat.com>

All TTM driver have been converted to new io_mem_reserve/free
interface which allow driver to choose and return proper io
base, offset to core TTM for ioremapping if necessary. This
patch remove what is now deadcode.

V2 adapt to match with change in first patch of the patchset
V3 update after io_mem_reserve/io_mem_free callback balancing
V4 adjust to minor cleanup
V5 remove the needs ioremap flag

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c      |   22 ----------
 drivers/gpu/drm/ttm/ttm_bo_util.c |   80 ++++++-------------------------------
 include/drm/ttm/ttm_bo_api.h      |    4 +-
 include/drm/ttm/ttm_bo_driver.h   |   12 ------
 4 files changed, 13 insertions(+), 105 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2171f86..1f27cf2 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -79,8 +79,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)
 	printk(KERN_ERR TTM_PFX "    use_type: %d\n", man->use_type);
 	printk(KERN_ERR TTM_PFX "    flags: 0x%08X\n", man->flags);
 	printk(KERN_ERR TTM_PFX "    gpu_offset: 0x%08lX\n", man->gpu_offset);
-	printk(KERN_ERR TTM_PFX "    io_offset: 0x%08lX\n", man->io_offset);
-	printk(KERN_ERR TTM_PFX "    io_size: %ld\n", man->io_size);
 	printk(KERN_ERR TTM_PFX "    size: %llu\n", man->size);
 	printk(KERN_ERR TTM_PFX "    available_caching: 0x%08X\n",
 		man->available_caching);
@@ -1563,26 +1561,6 @@ bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
 	return true;
 }
 
-int ttm_bo_pci_offset(struct ttm_bo_device *bdev,
-		      struct ttm_mem_reg *mem,
-		      unsigned long *bus_base,
-		      unsigned long *bus_offset, unsigned long *bus_size)
-{
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
-
-	*bus_size = 0;
-	if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
-		return -EINVAL;
-
-	if (ttm_mem_reg_is_pci(bdev, mem)) {
-		*bus_offset = mem->mm_node->start << PAGE_SHIFT;
-		*bus_size = mem->num_pages << PAGE_SHIFT;
-		*bus_base = man->io_offset + (uintptr_t)man->io_addr;
-	}
-
-	return 0;
-}
-
 void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 8493f39..15d1bf3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -83,61 +83,33 @@ EXPORT_SYMBOL(ttm_bo_move_ttm);
 
 int ttm_mem_io_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
-	int ret;
+	int ret = 0;
 
-	if (bdev->driver->io_mem_reserve) {
-		if (!mem->bus.io_reserved) {
-			mem->bus.io_reserved = true;
-			ret = bdev->driver->io_mem_reserve(bdev, mem);
-			if (unlikely(ret != 0))
-				return ret;
-		}
-	} else {
-		ret = ttm_bo_pci_offset(bdev, mem, &mem->bus.base, &mem->bus.offset, &mem->bus.size);
-		if (unlikely(ret != 0))
-			return ret;
-		mem->bus.addr = man->io_addr;
-		mem->bus.is_iomem = (mem->bus.size > 0) ? 1 : 0;
+	if (!mem->bus.io_reserved) {
+		mem->bus.io_reserved = true;
+		ret = bdev->driver->io_mem_reserve(bdev, mem);
 	}
-	return 0;
+	return ret;
 }
 
 void ttm_mem_io_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
 {
-	if (bdev->driver->io_mem_reserve) {
-		if (mem->bus.io_reserved) {
-			mem->bus.io_reserved = false;
-			bdev->driver->io_mem_free(bdev, mem);
-		}
+	if (mem->bus.io_reserved) {
+		mem->bus.io_reserved = false;
+		bdev->driver->io_mem_free(bdev, mem);
 	}
 }
 
 int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
 			void **virtual)
 {
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
 	int ret;
-	void *addr;
 
 	*virtual = NULL;
 	ret = ttm_mem_io_reserve(bdev, mem);
 	if (ret)
 		return ret;
-
-	if (!(man->flags & TTM_MEMTYPE_FLAG_NEEDS_IOREMAP)) {
-		addr = mem->bus.addr;
-	} else {
-		if (mem->placement & TTM_PL_FLAG_WC)
-			addr = ioremap_wc(mem->bus.base + mem->bus.offset, mem->bus.size);
-		else
-			addr = ioremap_nocache(mem->bus.base + mem->bus.offset, mem->bus.size);
-		if (!addr) {
-			ttm_mem_io_free(bdev, mem);
-			return -ENOMEM;
-		}
-	}
-	*virtual = addr;
+	*virtual = mem->bus.addr;
 	return 0;
 }
 
@@ -147,9 +119,6 @@ void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
 	struct ttm_mem_type_manager *man;
 
 	man = &bdev->man[mem->mem_type];
-
-	if (virtual && (man->flags & TTM_MEMTYPE_FLAG_NEEDS_IOREMAP))
-		iounmap(virtual);
 	ttm_mem_io_free(bdev, mem);
 }
 
@@ -401,30 +370,6 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp)
 }
 EXPORT_SYMBOL(ttm_io_prot);
 
-static int ttm_bo_ioremap(struct ttm_buffer_object *bo,
-			  unsigned long offset,
-			  unsigned long size,
-			  struct ttm_bo_kmap_obj *map)
-{
-	struct ttm_bo_device *bdev = bo->bdev;
-	struct ttm_mem_reg *mem = &bo->mem;
-	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
-
-	if (!(man->flags & TTM_MEMTYPE_FLAG_NEEDS_IOREMAP)) {
-		map->bo_kmap_type = ttm_bo_map_premapped;
-		map->virtual = (void *)(((u8 *) bo->mem.bus.addr) + offset);
-	} else {
-		map->bo_kmap_type = ttm_bo_map_iomap;
-		if (mem->placement & TTM_PL_FLAG_WC)
-			map->virtual = ioremap_wc(bo->mem.bus.base + bo->mem.bus.offset + offset,
-						  size);
-		else
-			map->virtual = ioremap_nocache(bo->mem.bus.base + bo->mem.bus.offset + offset,
-						       size);
-	}
-	return (!map->virtual) ? -ENOMEM : 0;
-}
-
 static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
 			   unsigned long start_page,
 			   unsigned long num_pages,
@@ -495,7 +440,9 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
 	} else {
 		offset = start_page << PAGE_SHIFT;
 		size = num_pages << PAGE_SHIFT;
-		return ttm_bo_ioremap(bo, offset, size, map);
+		map->bo_kmap_type = ttm_bo_map_iomap;
+		map->virtual = (void *)(((u8 *) bo->mem.bus.addr) + offset);
+		return 0;
 	}
 }
 EXPORT_SYMBOL(ttm_bo_kmap);
@@ -506,7 +453,6 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
 		return;
 	switch (map->bo_kmap_type) {
 	case ttm_bo_map_iomap:
-		iounmap(map->virtual);
 		ttm_mem_io_free(map->bo->bdev, &map->bo->mem);
 		break;
 	case ttm_bo_map_vmap:
@@ -515,8 +461,6 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
 	case ttm_bo_map_kmap:
 		kunmap(map->page);
 		break;
-	case ttm_bo_map_premapped:
-		break;
 	default:
 		BUG();
 	}
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 3e273e0..f3171a2 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -282,8 +282,7 @@ struct ttm_buffer_object {
  *
  * Object describing a kernel mapping. Since a TTM bo may be located
  * in various memory types with various caching policies, the
- * mapping can either be an ioremap, a vmap, a kmap or part of a
- * premapped region.
+ * mapping can either be an ioremap, a vmap, a kmap.
  */
 
 #define TTM_BO_MAP_IOMEM_MASK 0x80
@@ -294,7 +293,6 @@ struct ttm_bo_kmap_obj {
 		ttm_bo_map_iomap        = 1 | TTM_BO_MAP_IOMEM_MASK,
 		ttm_bo_map_vmap         = 2,
 		ttm_bo_map_kmap         = 3,
-		ttm_bo_map_premapped    = 4 | TTM_BO_MAP_IOMEM_MASK,
 	} bo_kmap_type;
 	struct ttm_buffer_object *bo;
 };
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index da39865..7720b17 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -176,8 +176,6 @@ struct ttm_tt {
 
 #define TTM_MEMTYPE_FLAG_FIXED         (1 << 0)	/* Fixed (on-card) PCI memory */
 #define TTM_MEMTYPE_FLAG_MAPPABLE      (1 << 1)	/* Memory mappable */
-#define TTM_MEMTYPE_FLAG_NEEDS_IOREMAP (1 << 2)	/* Fixed memory needs ioremap
-						   before kernel access. */
 #define TTM_MEMTYPE_FLAG_CMA           (1 << 3)	/* Can't map aperture */
 
 /**
@@ -189,13 +187,6 @@ struct ttm_tt {
  * managed by this memory type.
  * @gpu_offset: If used, the GPU offset of the first managed page of
  * fixed memory or the first managed location in an aperture.
- * @io_offset: The io_offset of the first managed page of IO memory or
- * the first managed location in an aperture. For TTM_MEMTYPE_FLAG_CMA
- * memory, this should be set to NULL.
- * @io_size: The size of a managed IO region (fixed memory or aperture).
- * @io_addr: Virtual kernel address if the io region is pre-mapped. For
- * TTM_MEMTYPE_FLAG_NEEDS_IOREMAP there is no pre-mapped io map and
- * @io_addr should be set to NULL.
  * @size: Size of the managed region.
  * @available_caching: A mask of available caching types, TTM_PL_FLAG_XX,
  * as defined in ttm_placement_common.h
@@ -221,9 +212,6 @@ struct ttm_mem_type_manager {
 	bool use_type;
 	uint32_t flags;
 	unsigned long gpu_offset;
-	unsigned long io_offset;
-	unsigned long io_size;
-	void *io_addr;
 	uint64_t size;
 	uint32_t available_caching;
 	uint32_t default_caching;
-- 
1.6.6.1


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

  reply	other threads:[~2010-04-07 10:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 10:21 unmappable vram V7 Jerome Glisse
2010-04-07 10:21 ` [PATCH 01/13] drm/ttm: split no_wait argument in 2 GPU or reserve wait Jerome Glisse
2010-04-07 10:21   ` [PATCH 02/13] drm/radeon/kms: update to TTM no_wait splitted argument Jerome Glisse
2010-04-07 10:21     ` [PATCH 03/13] drm/nouveau: " Jerome Glisse
2010-04-07 10:21       ` [PATCH 04/13] drm/vmwgfx: " Jerome Glisse
2010-04-07 10:21         ` [PATCH 05/13] drm/ttm: ttm_fault callback to allow driver to handle bo placement V5 Jerome Glisse
2010-04-07 10:21           ` [PATCH 06/13] drm/radeon/kms: add support for new fault callback V6 Jerome Glisse
2010-04-07 10:21             ` [PATCH 07/13] drm/nouveau/kms: add support for new TTM fault callback V4 Jerome Glisse
2010-04-07 10:21               ` [PATCH 08/13] drm/vmwgfx: " Jerome Glisse
2010-04-07 10:21                 ` [PATCH 09/13] drm/radeon/kms: don't initialize TTM io memory manager field Jerome Glisse
2010-04-07 10:21                   ` [PATCH 10/13] drm/nouveau/kms: " Jerome Glisse
2010-04-07 10:21                     ` [PATCH 11/13] drm/vmwgfx: " Jerome Glisse
2010-04-07 10:21                       ` Jerome Glisse [this message]
2010-04-07 10:21                         ` [PATCH 13/13] drm/radeon/kms: enable use of unmappable VRAM V2 Jerome Glisse
2010-04-09  2:41           ` [PATCH 05/13] drm/ttm: ttm_fault callback to allow driver to handle bo placement V5 Dave Airlie
2010-04-09 12:39             ` Thomas Hellstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270635691-2933-13-git-send-email-jglisse@redhat.com \
    --to=jglisse@redhat.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.sf.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.