public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/23] drm: introduce drm_zalloc
@ 2007-08-27 20:57 m.kozlowski
  2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
                   ` (23 more replies)
  0 siblings, 24 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

Hello,

	As there are many places in drm code where drm_alloc + memset is used
this patch series introduces drm_zalloc and also makes use of drm_calloc where
needed. Most of these patches save some bytes so the benefit is a few kB saved
(gcc 4.1.2) with patch applied. Also some small (style, etc.) things are fixed.
This patch series does the conversion drm tree-wide. All patches were compile
tested.

Patches are against 2.6.23-rc3-mm1. Please review and apply.

Regards,

	Mariusz


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 21:36   ` Mariusz Kozlowski
  2007-08-28 19:58   ` Ian Romanick
  2007-08-27 20:57 ` [PATCH 02/23] drm_agpsupport.c: drm_alloc + memset to drm_zalloc m.kozlowski
                   ` (22 subsequent siblings)
  23 siblings, 2 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: add-drm_zalloc.diff --]
[-- Type: text/plain, Size: 1560 bytes --]

Add drm_zalloc().

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drmP.h             |    7 +++++++
 drivers/char/drm/drm_memory_debug.h |   17 ++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drmP.h
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drmP.h
@@ -1125,10 +1125,17 @@ static __inline__ void *drm_calloc(size_
 {
 	return kcalloc(nmemb, size, GFP_KERNEL);
 }
+
+/** Wrapper around kzalloc() */
+static __inline__ void *drm_zalloc(size_t size, int area)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
 #else
 extern void *drm_alloc(size_t size, int area);
 extern void drm_free(void *pt, size_t size, int area);
 extern void *drm_calloc(size_t nmemb, size_t size, int area);
+extern void *drm_zalloc(size_t size, int area);
 #endif
 
 /*@}*/
--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_memory_debug.h
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_memory_debug.h
@@ -167,13 +167,24 @@ void *drm_alloc (size_t size, int area) 
 void *drm_calloc (size_t nmemb, size_t size, int area) {
 	void *addr;
 
-	addr = drm_alloc (nmemb * size, area);
-	if (addr != NULL)
-		memset((void *)addr, 0, size * nmemb);
+	addr = drm_alloc(nmemb * size, area);
+	if (!addr)
+		memset(addr, 0, size * nmemb);
 
 	return addr;
 }
 
+void *drm_zalloc(size_t size, int area)
+{
+	void *addr;
+
+	addr = drm_alloc(size, area);
+	if (!addr)
+		memset(addr, 0, size);
+	
+	return addr;
+}
+
 void *drm_realloc (void *oldpt, size_t oldsize, size_t size, int area) {
 	void *pt;
 

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 02/23] drm_agpsupport.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
  2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 03/23] drm_auth.c: " m.kozlowski
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_agpsupport.diff --]
[-- Type: text/plain, Size: 1350 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_agpsupport.c | 13896 -> 13828 (-68 bytes)
 drivers/char/drm/drm_agpsupport.o | 120046 -> 119814 (-232 bytes)

 drivers/char/drm/drm_agpsupport.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_agpsupport.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_agpsupport.c
@@ -216,10 +216,10 @@ int drm_agp_alloc(struct drm_device *dev

 	if (!dev->agp || !dev->agp->acquired)
 		return -EINVAL;
-	if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
-		return -ENOMEM;

-	memset(entry, 0, sizeof(*entry));
+	entry = drm_zalloc(sizeof(*entry), DRM_MEM_AGPLISTS);
+	if (!entry)
+		return -ENOMEM;

 	pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
 	type = (u32) request->type;
@@ -444,11 +444,12 @@ int drm_agp_free_ioctl(struct inode *ino
  */
 struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 {
-	struct drm_agp_head *head = NULL;
+	struct drm_agp_head *head;

-	if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
+	head = drm_zalloc(sizeof(*head), DRM_MEM_AGPLISTS);
+	if (!head)
 		return NULL;
-	memset((void *)head, 0, sizeof(*head));
+
 	head->bridge = agp_find_bridge(dev->pdev);
 	if (!head->bridge) {
 		if (!(head->bridge = agp_backend_acquire(dev->pdev))) {

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 03/23] drm_auth.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
  2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
  2007-08-27 20:57 ` [PATCH 02/23] drm_agpsupport.c: drm_alloc + memset to drm_zalloc m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 04/23] drm_bufs.c: drm_alloc + memset to drm_alloc m.kozlowski
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_auth.diff --]
[-- Type: text/plain, Size: 833 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_auth.c | 5835 -> 5802 (-33 bytes)
 drivers/char/drm/drm_auth.o | 104968 -> 104860 (-108 bytes)

 drivers/char/drm/drm_auth.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_auth.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_auth.c
@@ -78,12 +78,11 @@ static int drm_add_magic(struct drm_devi

 	DRM_DEBUG("%d\n", magic);

-	entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
+	entry = drm_zalloc(sizeof(*entry), DRM_MEM_MAGIC);
 	if (!entry)
 		return -ENOMEM;
-	memset(entry, 0, sizeof(*entry));
-	entry->priv = priv;

+	entry->priv = priv;
 	entry->hash_item.key = (unsigned long)magic;
 	mutex_lock(&dev->struct_mutex);
 	drm_ht_insert_item(&dev->magiclist, &entry->hash_item);

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 04/23] drm_bufs.c: drm_alloc + memset to drm_alloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (2 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 03/23] drm_auth.c: " m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 05/23] drm_dma.c: drm_alloc + memset to drm_zalloc m.kozlowski
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_bufs.diff --]
[-- Type: text/plain, Size: 5704 bytes --]

This patch does dma_alloc and memset conversion to drm_zalloc or drm_calloc.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_bufs.c | 44959 -> 44420 (-539 bytes)
 drivers/char/drm/drm_bufs.o | 149686 -> 146822 (-2864 bytes)

 drivers/char/drm/drm_bufs.c |   31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_bufs.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_bufs.c
@@ -277,14 +277,13 @@ static int drm_addmap_core(struct drm_de
 		return -EINVAL;
 	}

-	list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
+	list = drm_zalloc(sizeof(*list), DRM_MEM_MAPS);
 	if (!list) {
 		if (map->type == _DRM_REGISTERS)
 			iounmap(map->handle);
 		drm_free(map, sizeof(*map), DRM_MEM_MAPS);
 		return -EINVAL;
 	}
-	memset(list, 0, sizeof(*list));
 	list->map = map;

 	mutex_lock(&dev->struct_mutex);
@@ -627,14 +626,13 @@ int drm_addbufs_agp(struct drm_device *
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

 	entry->buf_size = size;
 	entry->page_order = page_order;
@@ -658,7 +656,7 @@ int drm_addbufs_agp(struct drm_device *
 		buf->filp = NULL;

 		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
+		buf->dev_private = drm_zalloc(buf->dev_priv_size, DRM_MEM_BUFS);
 		if (!buf->dev_private) {
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
@@ -667,7 +665,6 @@ int drm_addbufs_agp(struct drm_device *
 			atomic_dec(&dev->buf_alloc);
 			return -ENOMEM;
 		}
-		memset(buf->dev_private, 0, buf->dev_priv_size);

 		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);

@@ -783,16 +780,15 @@ int drm_addbufs_pci(struct drm_device *
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

-	entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
+	entry->seglist = drm_calloc(count, sizeof(*entry->seglist),
 				   DRM_MEM_SEGS);
 	if (!entry->seglist) {
 		drm_free(entry->buflist,
@@ -801,7 +797,6 @@ int drm_addbufs_pci(struct drm_device *
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->seglist, 0, count * sizeof(*entry->seglist));

 	/* Keep the original pagelist until we know all the allocations
 	 * have succeeded
@@ -869,7 +864,7 @@ int drm_addbufs_pci(struct drm_device *
 			buf->filp = NULL;

 			buf->dev_priv_size = dev->driver->dev_priv_size;
-			buf->dev_private = drm_alloc(buf->dev_priv_size,
+			buf->dev_private = drm_zalloc(buf->dev_priv_size,
 						     DRM_MEM_BUFS);
 			if (!buf->dev_private) {
 				/* Set count correctly so we free the proper amount. */
@@ -885,7 +880,6 @@ int drm_addbufs_pci(struct drm_device *
 				atomic_dec(&dev->buf_alloc);
 				return -ENOMEM;
 			}
-			memset(buf->dev_private, 0, buf->dev_priv_size);

 			DRM_DEBUG("buffer %d @ %p\n",
 				  entry->buf_count, buf->address);
@@ -1015,14 +1009,13 @@ static int drm_addbufs_sg(struct drm_dev
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

 	entry->buf_size = size;
 	entry->page_order = page_order;
@@ -1047,7 +1040,7 @@ static int drm_addbufs_sg(struct drm_dev
 		buf->filp = NULL;

 		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
+		buf->dev_private = drm_zalloc(buf->dev_priv_size, DRM_MEM_BUFS);
 		if (!buf->dev_private) {
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
@@ -1057,8 +1050,6 @@ static int drm_addbufs_sg(struct drm_dev
 			return -ENOMEM;
 		}

-		memset(buf->dev_private, 0, buf->dev_priv_size);
-
 		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);

 		offset += alignment;
@@ -1177,14 +1168,13 @@ static int drm_addbufs_fb(struct drm_dev
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

 	entry->buf_size = size;
 	entry->page_order = page_order;
@@ -1208,7 +1198,7 @@ static int drm_addbufs_fb(struct drm_dev
 		buf->filp = NULL;

 		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
+		buf->dev_private = drm_zalloc(buf->dev_priv_size, DRM_MEM_BUFS);
 		if (!buf->dev_private) {
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
@@ -1217,7 +1207,6 @@ static int drm_addbufs_fb(struct drm_dev
 			atomic_dec(&dev->buf_alloc);
 			return -ENOMEM;
 		}
-		memset(buf->dev_private, 0, buf->dev_priv_size);

 		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 05/23] drm_dma.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (3 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 04/23] drm_bufs.c: drm_alloc + memset to drm_alloc m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 06/23] drm_drawable.c: drm_calloc " m.kozlowski
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_dma.diff --]
[-- Type: text/plain, Size: 910 bytes --]

This patch does the conversion of drm_alloc + memset to drm_zalloc.
The memset in loop is also superfluous and can be removed.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_dma.c | 4624 -> 4475 (-149 bytes)
 drivers/char/drm/drm_dma.o | 104277 -> 103917 (-360 bytes)

 drivers/char/drm/drm_dma.c |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_dma.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_dma.c
@@ -45,17 +45,10 @@
  */
 int drm_dma_setup(struct drm_device *dev)
 {
-	int i;
-
-	dev->dma = drm_alloc(sizeof(*dev->dma), DRM_MEM_DRIVER);
+	dev->dma = drm_zalloc(sizeof(*dev->dma), DRM_MEM_DRIVER);
 	if (!dev->dma)
 		return -ENOMEM;

-	memset(dev->dma, 0, sizeof(*dev->dma));
-
-	for (i = 0; i <= DRM_MAX_ORDER; i++)
-		memset(&dev->dma->bufs[i], 0, sizeof(dev->dma->bufs[0]));
-
 	return 0;
 }

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 06/23] drm_drawable.c: drm_calloc to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (4 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 05/23] drm_dma.c: drm_alloc + memset to drm_zalloc m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 07/23] drm_fops.c: drm_alloc + memset " m.kozlowski
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_drawable.diff --]
[-- Type: text/plain, Size: 729 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_drawable.c | 5425 -> 5422 (-3 bytes)
 drivers/char/drm/drm_drawable.o | 108201 -> 107765 (-436 bytes)

 drivers/char/drm/drm_drawable.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_drawable.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_drawable.c
@@ -110,7 +110,7 @@ int drm_update_drawable_info(DRM_IOCTL_A

 	info = idr_find(&dev->drw_idr, update.handle);
 	if (!info) {
-		info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS);
+		info = drm_zalloc(sizeof(*info), DRM_MEM_BUFS);
 		if (!info)
 			return -ENOMEM;
 		if (IS_ERR(idr_replace(&dev->drw_idr, info, update.handle))) {

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 07/23] drm_fops.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (5 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 06/23] drm_drawable.c: drm_calloc " m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 08/23] drm_irq.c: " m.kozlowski
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_fops.diff --]
[-- Type: text/plain, Size: 761 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_fops.c | 11849 -> 11817 (-32 bytes)
 drivers/char/drm/drm_fops.o | 115963 -> 115177 (-786 bytes)

 drivers/char/drm/drm_fops.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_fops.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_fops.c
@@ -236,11 +236,10 @@ static int drm_open_helper(struct inode

 	DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);

-	priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
+	priv = drm_zalloc(sizeof(*priv), DRM_MEM_FILES);
 	if (!priv)
 		return -ENOMEM;

-	memset(priv, 0, sizeof(*priv));
 	filp->private_data = priv;
 	priv->uid = current->euid;
 	priv->pid = current->pid;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 08/23] drm_irq.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (6 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 07/23] drm_fops.c: drm_alloc + memset " m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:57 ` [PATCH 09/23] drm_scatter.c: drm_alloc + memset to drm_alloc m.kozlowski
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_irq.diff --]
[-- Type: text/plain, Size: 853 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_irq.c | 13062 -> 13003 (-59 bytes)
 drivers/char/drm/drm_irq.o | 114446 -> 114298 (-148 bytes)

 drivers/char/drm/drm_irq.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_irq.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_irq.c
@@ -322,13 +322,9 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)

 		spin_unlock_irqrestore(&dev->vbl_lock, irqflags);

-		if (!
-		    (vbl_sig =
-		     drm_alloc(sizeof(struct drm_vbl_sig), DRM_MEM_DRIVER))) {
+		vbl_sig = drm_zalloc(sizeof(struct drm_vbl_sig), DRM_MEM_DRIVER);
+		if (!vbl_sig)
 			return -ENOMEM;
-		}
-
-		memset((void *)vbl_sig, 0, sizeof(*vbl_sig));

 		vbl_sig->sequence = vblwait.request.sequence;
 		vbl_sig->info.si_signo = vblwait.request.signal;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 09/23] drm_scatter.c: drm_alloc + memset to drm_alloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (7 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 08/23] drm_irq.c: " m.kozlowski
@ 2007-08-27 20:57 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 10/23] drm_sman.c: drm_calloc to drm_zalloc m.kozlowski
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:57 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_scatter.diff --]
[-- Type: text/plain, Size: 1671 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_scatter.c | 6113 -> 5945 (-168 bytes)
 drivers/char/drm/drm_scatter.o | 105552 -> 105584 (+32 bytes)

 drivers/char/drm/drm_scatter.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_scatter.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_scatter.c
@@ -83,26 +83,22 @@ int drm_sg_alloc(struct inode *inode, st
 	if (copy_from_user(&request, argp, sizeof(request)))
 		return -EFAULT;

-	entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS);
+	entry = drm_zalloc(sizeof(*entry), DRM_MEM_SGLISTS);
 	if (!entry)
 		return -ENOMEM;

-	memset(entry, 0, sizeof(*entry));
-
 	pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
 	DRM_DEBUG("sg size=%ld pages=%ld\n", request.size, pages);

 	entry->pages = pages;
-	entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist),
+	entry->pagelist = drm_calloc(pages, sizeof(*entry->pagelist),
 				    DRM_MEM_PAGES);
 	if (!entry->pagelist) {
 		drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
 		return -ENOMEM;
 	}

-	memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
-
-	entry->busaddr = drm_alloc(pages * sizeof(*entry->busaddr),
+	entry->busaddr = drm_calloc(pages, sizeof(*entry->busaddr),
 				   DRM_MEM_PAGES);
 	if (!entry->busaddr) {
 		drm_free(entry->pagelist,
@@ -111,7 +107,6 @@ int drm_sg_alloc(struct inode *inode, st
 		drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
 		return -ENOMEM;
 	}
-	memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));

 	entry->virtual = vmalloc_32(pages << PAGE_SHIFT);
 	if (!entry->virtual) {

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 10/23] drm_sman.c: drm_calloc to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (8 preceding siblings ...)
  2007-08-27 20:57 ` [PATCH 09/23] drm_scatter.c: drm_alloc + memset to drm_alloc m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 11/23] drm_stub.c: " m.kozlowski
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_sman.diff --]
[-- Type: text/plain, Size: 1206 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_sman.c | 9108 -> 9094 (-14 bytes)
 drivers/char/drm/drm_sman.o | 104466 -> 103946 (-520 bytes)

 drivers/char/drm/drm_sman.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_sman.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_sman.c
@@ -130,10 +130,10 @@ drm_sman_set_range(struct drm_sman * sma
 	BUG_ON(manager >= sman->num_managers);

 	sman_mm = &sman->mm[manager];
-	mm = drm_calloc(1, sizeof(*mm), DRM_MEM_MM);
-	if (!mm) {
+	mm = drm_zalloc(sizeof(*mm), DRM_MEM_MM);
+	if (!mm)
 		return -ENOMEM;
-	}
+
 	sman_mm->private = mm;
 	ret = drm_mm_init(mm, start, size);

@@ -176,7 +176,7 @@ static struct drm_owner_item *drm_sman_g
 				      owner_hash);
 	}

-	owner_item = drm_calloc(1, sizeof(*owner_item), DRM_MEM_MM);
+	owner_item = drm_zalloc(sizeof(*owner_item), DRM_MEM_MM);
 	if (!owner_item)
 		goto out;

@@ -212,8 +212,7 @@ struct drm_memblock_item *drm_sman_alloc
 		return NULL;
 	}

-	memblock = drm_calloc(1, sizeof(*memblock), DRM_MEM_MM);
-
+	memblock = drm_zalloc(sizeof(*memblock), DRM_MEM_MM);
 	if (!memblock)
 		goto out;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 11/23] drm_stub.c: drm_calloc to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (9 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 10/23] drm_sman.c: drm_calloc to drm_zalloc m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 12/23] i810_dma.c: drm_alloc + memset " m.kozlowski
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: drm_stub.diff --]
[-- Type: text/plain, Size: 591 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/drm_stub.c | 7731 -> 7728 (-3 bytes)
 drivers/char/drm/drm_stub.o | 110301 -> 111354 (+1053 bytes)

 drivers/char/drm/drm_stub.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_stub.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_stub.c
@@ -210,7 +210,7 @@ int drm_get_dev(struct pci_dev *pdev, co

 	DRM_DEBUG("\n");

-	dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB);
+	dev = drm_zalloc(sizeof(*dev), DRM_MEM_STUB);
 	if (!dev)
 		return -ENOMEM;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 12/23] i810_dma.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (10 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 11/23] drm_stub.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 13/23] i830_dma.c: " m.kozlowski
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: i810_dma.diff --]
[-- Type: text/plain, Size: 1389 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/i810_dma.c | 37542 -> 37480 (-62 bytes)
 drivers/char/drm/i810_dma.o | 150664 -> 149996 (-668 bytes)

 drivers/char/drm/i810_dma.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/i810_dma.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/i810_dma.c
@@ -328,7 +328,6 @@ static int i810_dma_initialize(struct dr
 			       drm_i810_init_t * init)
 {
 	struct drm_map_list *r_list;
-	memset(dev_priv, 0, sizeof(drm_i810_private_t));

 	list_for_each_entry(r_list, &dev->maplist, head) {
 		if (r_list->map &&
@@ -498,9 +497,9 @@ static int i810_dma_init(struct inode *i
 		if (retcode)
 			return retcode;

-		dev_priv = drm_alloc(sizeof(drm_i810_private_t),
+		dev_priv = drm_zalloc(sizeof(drm_i810_private_t),
 				     DRM_MEM_DRIVER);
-		if (dev_priv == NULL)
+		if (!dev_priv)
 			return -ENOMEM;
 		retcode = i810_dma_initialize(dev, dev_priv, &init);
 		break;
@@ -512,9 +511,9 @@ static int i810_dma_init(struct inode *i
 				   sizeof(drm_i810_init_t))) {
 			return -EFAULT;
 		}
-		dev_priv = drm_alloc(sizeof(drm_i810_private_t),
+		dev_priv = drm_zalloc(sizeof(drm_i810_private_t),
 				     DRM_MEM_DRIVER);
-		if (dev_priv == NULL)
+		if (!dev_priv)
 			return -ENOMEM;
 		retcode = i810_dma_initialize(dev, dev_priv, &init);
 		break;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 13/23] i830_dma.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (11 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 12/23] i810_dma.c: drm_alloc + memset " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 14/23] i915_dma.c: " m.kozlowski
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: i830_dma.diff --]
[-- Type: text/plain, Size: 1019 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/i830_dma.c | 41269 -> 41212 (-57 bytes)
 drivers/char/drm/i830_dma.o | 157920 -> 157480 (-440 bytes)

 drivers/char/drm/i830_dma.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/i830_dma.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/i830_dma.c
@@ -336,8 +336,6 @@ static int i830_dma_initialize(struct dr
 {
 	struct drm_map_list *r_list;

-	memset(dev_priv, 0, sizeof(drm_i830_private_t));
-
 	list_for_each_entry(r_list, &dev->maplist, head) {
 		if (r_list->map &&
 		    r_list->map->type == _DRM_SHM &&
@@ -465,9 +463,9 @@ static int i830_dma_init(struct inode *i

 	switch (init.func) {
 	case I830_INIT_DMA:
-		dev_priv = drm_alloc(sizeof(drm_i830_private_t),
+		dev_priv = drm_zalloc(sizeof(drm_i830_private_t),
 				     DRM_MEM_DRIVER);
-		if (dev_priv == NULL)
+		if (!dev_priv)
 			return -ENOMEM;
 		retcode = i830_dma_initialize(dev, dev_priv, &init);
 		break;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 14/23] i915_dma.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (12 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 13/23] i830_dma.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 15/23] i915_irq.c: drm_calloc to drm_zalloc and bugfix m.kozlowski
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: i915_dma.diff --]
[-- Type: text/plain, Size: 1049 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/i915_dma.c | 22680 -> 22623 (-57 bytes)
 drivers/char/drm/i915_dma.o | 134192 -> 133704 (-488 bytes)

 drivers/char/drm/i915_dma.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/i915_dma.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/i915_dma.c
@@ -130,8 +130,6 @@ static int i915_initialize(struct drm_de
 			   drm_i915_private_t * dev_priv,
 			   drm_i915_init_t * init)
 {
-	memset(dev_priv, 0, sizeof(drm_i915_private_t));
-
 	dev_priv->sarea = drm_getsarea(dev);
 	if (!dev_priv->sarea) {
 		DRM_ERROR("can not find sarea!\n");
@@ -263,9 +261,9 @@ static int i915_dma_init(DRM_IOCTL_ARGS)

 	switch (init.func) {
 	case I915_INIT_DMA:
-		dev_priv = drm_alloc(sizeof(drm_i915_private_t),
+		dev_priv = drm_zalloc(sizeof(drm_i915_private_t),
 				     DRM_MEM_DRIVER);
-		if (dev_priv == NULL)
+		if (!dev_priv)
 			return DRM_ERR(ENOMEM);
 		retcode = i915_initialize(dev, dev_priv, &init);
 		break;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 15/23] i915_irq.c: drm_calloc to drm_zalloc and bugfix
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (13 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 14/23] i915_dma.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 16/23] i915_mem.c: drm_alloc + memset to drm_zalloc m.kozlowski
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: i915_irq.diff --]
[-- Type: text/plain, Size: 917 bytes --]

This patch does drm_calloc to drm_zalloc conversion. Also it
seems that unpatched version allocated wrong nr of bytes.

drm_i915_vbl_swap_t *vbl_swap;

...

sizeof(vbl_swap) vs. sizeof(*vbl_swap)

No?

Please review.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/i915_irq.c | 15749 -> 15746 (-3 bytes)
 drivers/char/drm/i915_irq.o | 128940 -> 128856 (-84 bytes)

 drivers/char/drm/i915_irq.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)


--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/i915_irq.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/i915_irq.c
@@ -541,8 +541,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
 		return DRM_ERR(EBUSY);
 	}

-	vbl_swap = drm_calloc(1, sizeof(vbl_swap), DRM_MEM_DRIVER);
-
+	vbl_swap = drm_zalloc(sizeof(*vbl_swap), DRM_MEM_DRIVER);
 	if (!vbl_swap) {
 		DRM_ERROR("Failed to allocate memory to queue swap\n");
 		return DRM_ERR(ENOMEM);

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 16/23] i915_mem.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (14 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 15/23] i915_irq.c: drm_calloc to drm_zalloc and bugfix m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 17/23] mga_dma.c: " m.kozlowski
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: i915_mem.diff --]
[-- Type: text/plain, Size: 925 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/i915_mem.c | 9842 -> 9808 (-34 bytes)
 drivers/char/drm/i915_mem.o | 114556 -> 114464 (-92 bytes)

 drivers/char/drm/i915_mem.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/i915_mem.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/i915_mem.c
@@ -189,7 +189,7 @@ static int init_heap(struct mem_block **
 	if (!blocks)
 		return -ENOMEM;

-	*heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS);
+	*heap = drm_zalloc(sizeof(**heap), DRM_MEM_BUFLISTS);
 	if (!*heap) {
 		drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
 		return -ENOMEM;
@@ -200,7 +200,6 @@ static int init_heap(struct mem_block **
 	blocks->filp = NULL;
 	blocks->next = blocks->prev = *heap;

-	memset(*heap, 0, sizeof(**heap));
 	(*heap)->filp = (DRMFILE) - 1;
 	(*heap)->next = (*heap)->prev = blocks;
 	return 0;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 17/23] mga_dma.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (15 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 16/23] i915_mem.c: drm_alloc + memset to drm_zalloc m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 18/23] r128_cce.c: " m.kozlowski
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: mga_dma.diff --]
[-- Type: text/plain, Size: 1764 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/mga_dma.c | 30418 -> 30253 (-165 bytes)
 drivers/char/drm/mga_dma.o | 140668 -> 140304 (-364 bytes)

 drivers/char/drm/mga_dma.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/mga_dma.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/mga_dma.c
@@ -254,23 +254,20 @@ static int mga_freelist_init(struct drm_
 	int i;
 	DRM_DEBUG("count=%d\n", dma->buf_count);

-	dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
-	if (dev_priv->head == NULL)
+	dev_priv->head = drm_zalloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+	if (!dev_priv->head)
 		return DRM_ERR(ENOMEM);

-	memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t));
 	SET_AGE(&dev_priv->head->age, MGA_BUFFER_USED, 0);

 	for (i = 0; i < dma->buf_count; i++) {
 		buf = dma->buflist[i];
 		buf_priv = buf->dev_private;

-		entry = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
-		if (entry == NULL)
+		entry = drm_zalloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+		if (!entry)
 			return DRM_ERR(ENOMEM);

-		memset(entry, 0, sizeof(drm_mga_freelist_t));
-
 		entry->next = dev_priv->head->next;
 		entry->prev = dev_priv->head;
 		SET_AGE(&entry->age, MGA_BUFFER_FREE, 0);
@@ -397,12 +394,11 @@ int mga_driver_load(struct drm_device *
 {
 	drm_mga_private_t *dev_priv;

-	dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
+	dev_priv = drm_zalloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
 	if (!dev_priv)
 		return DRM_ERR(ENOMEM);

 	dev->dev_private = (void *)dev_priv;
-	memset(dev_priv, 0, sizeof(drm_mga_private_t));

 	dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
 	dev_priv->chipset = flags;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 18/23] r128_cce.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (16 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 17/23] mga_dma.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 19/23] radeon_cp.c: " m.kozlowski
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: r128_cce.diff --]
[-- Type: text/plain, Size: 1287 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/r128_cce.c | 25912 -> 25792 (-120 bytes)
 drivers/char/drm/r128_cce.o | 133640 -> 133468 (-172 bytes)

 drivers/char/drm/r128_cce.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/r128_cce.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/r128_cce.c
@@ -353,12 +353,10 @@ static int r128_do_init_cce(struct drm_d

 	DRM_DEBUG("\n");

-	dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER);
-	if (dev_priv == NULL)
+	dev_priv = drm_zalloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER);
+	if (!dev_priv)
 		return DRM_ERR(ENOMEM);

-	memset(dev_priv, 0, sizeof(drm_r128_private_t));
-
 	dev_priv->is_pci = init->is_pci;

 	if (dev_priv->is_pci && !dev->sg) {
@@ -778,11 +776,10 @@ static int r128_freelist_init(struct drm
 	drm_r128_freelist_t *entry;
 	int i;

-	dev_priv->head = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER);
-	if (dev_priv->head == NULL)
+	dev_priv->head = drm_zalloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER);
+	if (!dev_priv->head)
 		return DRM_ERR(ENOMEM);

-	memset(dev_priv->head, 0, sizeof(drm_r128_freelist_t));
 	dev_priv->head->age = R128_BUFFER_USED;

 	for (i = 0; i < dma->buf_count; i++) {

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 19/23] radeon_cp.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (17 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 18/23] r128_cce.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 20/23] radeon_mem.c: " m.kozlowski
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: radeon_cp.diff --]
[-- Type: text/plain, Size: 834 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/radeon_cp.c | 62519 -> 62461 (-58 bytes)
 drivers/char/drm/radeon_cp.o | 160564 -> 160596 (+32 bytes)

 drivers/char/drm/radeon_cp.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/radeon_cp.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/radeon_cp.c
@@ -2239,11 +2239,10 @@ int radeon_driver_load(struct drm_device
 	drm_radeon_private_t *dev_priv;
 	int ret = 0;

-	dev_priv = drm_alloc(sizeof(drm_radeon_private_t), DRM_MEM_DRIVER);
-	if (dev_priv == NULL)
+	dev_priv = drm_zalloc(sizeof(drm_radeon_private_t), DRM_MEM_DRIVER);
+	if (!dev_priv)
 		return DRM_ERR(ENOMEM);

-	memset(dev_priv, 0, sizeof(drm_radeon_private_t));
 	dev->dev_private = (void *)dev_priv;
 	dev_priv->flags = flags;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 20/23] radeon_mem.c: drm_alloc + memset to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (18 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 19/23] radeon_cp.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 21/23] savage_bci.c: drm_alloc + memset to drm_zalloc and cleanup m.kozlowski
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: radeon_mem.diff --]
[-- Type: text/plain, Size: 939 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/radeon_mem.c | 7711 -> 7677 (-34 bytes)
 drivers/char/drm/radeon_mem.o | 115484 -> 115396 (-88 bytes)

 drivers/char/drm/radeon_mem.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/radeon_mem.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/radeon_mem.c
@@ -139,7 +139,7 @@ static int init_heap(struct mem_block **
 	if (!blocks)
 		return DRM_ERR(ENOMEM);

-	*heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS);
+	*heap = drm_zalloc(sizeof(**heap), DRM_MEM_BUFS);
 	if (!*heap) {
 		drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFS);
 		return DRM_ERR(ENOMEM);
@@ -150,7 +150,6 @@ static int init_heap(struct mem_block **
 	blocks->filp = NULL;
 	blocks->next = blocks->prev = *heap;

-	memset(*heap, 0, sizeof(**heap));
 	(*heap)->filp = (DRMFILE) - 1;
 	(*heap)->next = (*heap)->prev = blocks;
 	return 0;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 21/23] savage_bci.c: drm_alloc + memset to drm_zalloc and cleanup
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (19 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 20/23] radeon_mem.c: " m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 22/23] sis_drv.c: drm_calloc to drm_zalloc m.kozlowski
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: savage_bci.diff --]
[-- Type: text/plain, Size: 1784 bytes --]

The initialization in for loop can be removed as the SET_AGE macro
set the age struct and other members to zero.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/savage_bci.c | 31888 -> 31634 (-254 bytes)
 drivers/char/drm/savage_bci.o | 138936 -> 138984 (+48 bytes)

 drivers/char/drm/savage_bci.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/savage_bci.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/savage_bci.c
@@ -294,20 +294,13 @@ void savage_freelist_put(struct drm_devi
  */
 static int savage_dma_init(drm_savage_private_t * dev_priv)
 {
-	unsigned int i;
-
 	dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
 	    (SAVAGE_DMA_PAGE_SIZE * 4);
-	dev_priv->dma_pages = drm_alloc(sizeof(drm_savage_dma_page_t) *
-					dev_priv->nr_dma_pages, DRM_MEM_DRIVER);
-	if (dev_priv->dma_pages == NULL)
+	dev_priv->dma_pages = drm_calloc(dev_priv->nr_dma_pages,
+				sizeof(drm_savage_dma_page_t), DRM_MEM_DRIVER);
+	if (!dev_priv->dma_pages)
 		return DRM_ERR(ENOMEM);

-	for (i = 0; i < dev_priv->nr_dma_pages; ++i) {
-		SET_AGE(&dev_priv->dma_pages[i].age, 0, 0);
-		dev_priv->dma_pages[i].used = 0;
-		dev_priv->dma_pages[i].flushed = 0;
-	}
 	SET_AGE(&dev_priv->last_dma_age, 0, 0);

 	dev_priv->first_dma_page = 0;
@@ -539,11 +532,10 @@ int savage_driver_load(struct drm_device
 {
 	drm_savage_private_t *dev_priv;

-	dev_priv = drm_alloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
-	if (dev_priv == NULL)
+	dev_priv = drm_zalloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
+	if (!dev_priv)
 		return DRM_ERR(ENOMEM);

-	memset(dev_priv, 0, sizeof(drm_savage_private_t));
 	dev->dev_private = (void *)dev_priv;

 	dev_priv->chipset = (enum savage_family)chipset;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 22/23] sis_drv.c: drm_calloc to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (20 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 21/23] savage_bci.c: drm_alloc + memset to drm_zalloc and cleanup m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-27 20:58 ` [PATCH 23/23] via_map.c: " m.kozlowski
  2007-08-28 20:08 ` [PATCH 00/23] drm: introduce drm_zalloc Christoph Hellwig
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: sis_drv.diff --]
[-- Type: text/plain, Size: 727 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/sis_drv.c | 3249 -> 3239 (-10 bytes)
 drivers/char/drm/sis_drv.o | 104756 -> 105460 (+704 bytes)

 drivers/char/drm/sis_drv.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/sis_drv.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/sis_drv.c
@@ -40,8 +40,8 @@ static int sis_driver_load(struct drm_de
 	drm_sis_private_t *dev_priv;
 	int ret;

-	dev_priv = drm_calloc(1, sizeof(drm_sis_private_t), DRM_MEM_DRIVER);
-	if (dev_priv == NULL)
+	dev_priv = drm_zalloc(sizeof(drm_sis_private_t), DRM_MEM_DRIVER);
+	if (!dev_priv)
 		return DRM_ERR(ENOMEM);

 	dev->dev_private = (void *)dev_priv;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 23/23] via_map.c: drm_calloc to drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (21 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 22/23] sis_drv.c: drm_calloc to drm_zalloc m.kozlowski
@ 2007-08-27 20:58 ` m.kozlowski
  2007-08-28 20:08 ` [PATCH 00/23] drm: introduce drm_zalloc Christoph Hellwig
  23 siblings, 0 replies; 31+ messages in thread
From: m.kozlowski @ 2007-08-27 20:58 UTC (permalink / raw)
  To: airlied, akpm; +Cc: dri-devel, linux-kernel

[-- Attachment #1: via_map.diff --]
[-- Type: text/plain, Size: 733 bytes --]

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

 drivers/char/drm/via_map.c | 3449 -> 3439 (-10 bytes)
 drivers/char/drm/via_map.o | 110028 -> 110488 (+460 bytes)

 drivers/char/drm/via_map.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/via_map.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/via_map.c
@@ -100,8 +100,8 @@ int via_driver_load(struct drm_device *d
 	drm_via_private_t *dev_priv;
 	int ret = 0;

-	dev_priv = drm_calloc(1, sizeof(drm_via_private_t), DRM_MEM_DRIVER);
-	if (dev_priv == NULL)
+	dev_priv = drm_zalloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
+	if (!dev_priv)
 		return DRM_ERR(ENOMEM);

 	dev->dev_private = (void *)dev_priv;

--

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement
  2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
@ 2007-08-27 21:36   ` Mariusz Kozlowski
  2007-08-28 19:58   ` Ian Romanick
  1 sibling, 0 replies; 31+ messages in thread
From: Mariusz Kozlowski @ 2007-08-27 21:36 UTC (permalink / raw)
  To: airlied; +Cc: akpm, dri-devel, linux-kernel

> Add drm_zalloc().

Ugh. Too fast. Ofcourse this is the correct version. Sorry.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

--- linux-2.6.23-rc3-mm1-a/drivers/char/drm/drmP.h	2007-08-27 18:32:26.000000000 +0200
+++ linux-2.6.23-rc3-mm1-b/drivers/char/drm/drmP.h	2007-08-26 15:34:40.000000000 +0200
@@ -1125,10 +1125,17 @@ static __inline__ void *drm_calloc(size_
 {
 	return kcalloc(nmemb, size, GFP_KERNEL);
 }
+
+/** Wrapper around kzalloc() */
+static __inline__ void *drm_zalloc(size_t size, int area)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
 #else
 extern void *drm_alloc(size_t size, int area);
 extern void drm_free(void *pt, size_t size, int area);
 extern void *drm_calloc(size_t nmemb, size_t size, int area);
+extern void *drm_zalloc(size_t size, int area);
 #endif

 /*@}*/
--- linux-2.6.23-rc3-mm1-a/drivers/char/drm/drm_memory_debug.h	2007-08-27 18:32:26.000000000 +0200
+++ linux-2.6.23-rc3-mm1-b/drivers/char/drm/drm_memory_debug.h	2007-08-27 23:28:31.000000000 +0200
@@ -167,13 +167,24 @@ void *drm_alloc (size_t size, int area)
 void *drm_calloc (size_t nmemb, size_t size, int area) {
 	void *addr;

-	addr = drm_alloc (nmemb * size, area);
-	if (addr != NULL)
-		memset((void *)addr, 0, size * nmemb);
+	addr = drm_alloc(nmemb * size, area);
+	if (addr)
+		memset(addr, 0, size * nmemb);

 	return addr;
 }

+void *drm_zalloc(size_t size, int area)
+{
+	void *addr;
+
+	addr = drm_alloc(size, area);
+	if (addr)
+		memset(addr, 0, size);
+
+	return addr;
+}
+
 void *drm_realloc (void *oldpt, size_t oldsize, size_t size, int area) {
 	void *pt;


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement
  2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
  2007-08-27 21:36   ` Mariusz Kozlowski
@ 2007-08-28 19:58   ` Ian Romanick
  1 sibling, 0 replies; 31+ messages in thread
From: Ian Romanick @ 2007-08-28 19:58 UTC (permalink / raw)
  To: m.kozlowski; +Cc: dri-devel, linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Instead of adding drm_zalloc, why not just use drm_calloc?  At the very
least just make drm_zalloc a macro that calls drm_calloc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFG1H5pX1gOwKyEAw8RAuXrAJ9W+Oyaimcedg0LdDqwqfMgX9Gl2QCeM9BM
sdiP4BDvLirsYex5hqhHsFc=
=/qZb
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/23] drm: introduce drm_zalloc
  2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
                   ` (22 preceding siblings ...)
  2007-08-27 20:58 ` [PATCH 23/23] via_map.c: " m.kozlowski
@ 2007-08-28 20:08 ` Christoph Hellwig
  2007-08-28 20:50   ` Dave Airlie
  23 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2007-08-28 20:08 UTC (permalink / raw)
  To: m.kozlowski; +Cc: airlied, akpm, dri-devel, linux-kernel

On Mon, Aug 27, 2007 at 10:57:50PM +0200, m.kozlowski@tuxland.pl wrote:
> Hello,
> 
> 	As there are many places in drm code where drm_alloc + memset is used
> this patch series introduces drm_zalloc and also makes use of drm_calloc where
> needed. Most of these patches save some bytes so the benefit is a few kB saved
> (gcc 4.1.2) with patch applied. Also some small (style, etc.) things are fixed.
> This patch series does the conversion drm tree-wide. All patches were compile
> tested.

Please just convert it to plain kzalloc/kcalloc and kill these utterly useless
wrappers instead.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/23] drm: introduce drm_zalloc
  2007-08-28 20:08 ` [PATCH 00/23] drm: introduce drm_zalloc Christoph Hellwig
@ 2007-08-28 20:50   ` Dave Airlie
  2007-08-30 16:20     ` Kristian Høgsberg
  0 siblings, 1 reply; 31+ messages in thread
From: Dave Airlie @ 2007-08-28 20:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: m.kozlowski, akpm, dri-devel, linux-kernel

On Tue, 28 Aug 2007, Christoph Hellwig wrote:

> On Mon, Aug 27, 2007 at 10:57:50PM +0200, m.kozlowski@tuxland.pl wrote:
>> Hello,
>>
>> 	As there are many places in drm code where drm_alloc + memset is used
>> this patch series introduces drm_zalloc and also makes use of drm_calloc where
>> needed. Most of these patches save some bytes so the benefit is a few kB saved
>> (gcc 4.1.2) with patch applied. Also some small (style, etc.) things are fixed.
>> This patch series does the conversion drm tree-wide. All patches were compile
>> tested.
>
> Please just convert it to plain kzalloc/kcalloc and kill these utterly useless
> wrappers instead.
>
>

The wrappers aren't useless the drm alloc/free passes in a memory space 
for debugging purposes so we can track memory abuse when developing,

but drm_zalloc shouldjust alias to drm_calloc really..

Dave.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/23] drm: introduce drm_zalloc
  2007-08-28 20:50   ` Dave Airlie
@ 2007-08-30 16:20     ` Kristian Høgsberg
  2007-08-30 16:24       ` Christoph Hellwig
  0 siblings, 1 reply; 31+ messages in thread
From: Kristian Høgsberg @ 2007-08-30 16:20 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Christoph Hellwig, m.kozlowski, akpm, dri-devel, linux-kernel


On Tue, 2007-08-28 at 21:50 +0100, Dave Airlie wrote:
> On Tue, 28 Aug 2007, Christoph Hellwig wrote:
> 
> > On Mon, Aug 27, 2007 at 10:57:50PM +0200, m.kozlowski@tuxland.pl wrote:
> >> Hello,
> >>
> >> 	As there are many places in drm code where drm_alloc + memset is used
> >> this patch series introduces drm_zalloc and also makes use of drm_calloc where
> >> needed. Most of these patches save some bytes so the benefit is a few kB saved
> >> (gcc 4.1.2) with patch applied. Also some small (style, etc.) things are fixed.
> >> This patch series does the conversion drm tree-wide. All patches were compile
> >> tested.
> >
> > Please just convert it to plain kzalloc/kcalloc and kill these utterly useless
> > wrappers instead.
> >
> >
> 
> The wrappers aren't useless the drm alloc/free passes in a memory space 
> for debugging purposes so we can track memory abuse when developing,

Do we ever use that, though?  Having to pass in the pointer, the size
and the area just to free memory, sure is a bitch.

> but drm_zalloc shouldjust alias to drm_calloc really..

drm_calloc calls kcalloc which performs an integer overflow check on the
'n' and 'size' arguments, which isn't needed for drm_zalloc.  Small
detail, of course, but I don't see the problem with aliasing to kzalloc.

Kristian



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/23] drm: introduce drm_zalloc
  2007-08-30 16:20     ` Kristian Høgsberg
@ 2007-08-30 16:24       ` Christoph Hellwig
  2007-08-30 23:20         ` Dave Airlie
  0 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2007-08-30 16:24 UTC (permalink / raw)
  To: Kristian H?gsberg
  Cc: Dave Airlie, Christoph Hellwig, m.kozlowski, akpm, dri-devel,
	linux-kernel

On Thu, Aug 30, 2007 at 12:20:32PM -0400, Kristian H?gsberg wrote:
> > The wrappers aren't useless the drm alloc/free passes in a memory space 
> > for debugging purposes so we can track memory abuse when developing,
> 
> Do we ever use that, though?  Having to pass in the pointer, the size
> and the area just to free memory, sure is a bitch.

Note the slab has a memory tracking feature that accounts memory to
callers of the allocator.  IF that's not enough for you please help
improving the common code instead of inventing your own.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/23] drm: introduce drm_zalloc
  2007-08-30 16:24       ` Christoph Hellwig
@ 2007-08-30 23:20         ` Dave Airlie
  0 siblings, 0 replies; 31+ messages in thread
From: Dave Airlie @ 2007-08-30 23:20 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kristian H?gsberg, linux-kernel, m.kozlowski, akpm, dri-devel

>
> Note the slab has a memory tracking feature that accounts memory to
> callers of the allocator.  IF that's not enough for you please help
> improving the common code instead of inventing your own.

Christoph that code was written over 6-7 years ago, feel free to provide a 
patch for it to use the slab allocator, we only turn this code on though 
when developing new drivers, I don't think it ever gets used outside of 
that.. we don't need the overhead of the memory tracking in normal use..

Please stop implying that all the code in the drm is magically new and 
that we should be reusing kernel infrastructure that wasn't even written 
when the code first appeared.. or provide patches...

Dave.

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2007-08-30 23:20 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
2007-08-27 21:36   ` Mariusz Kozlowski
2007-08-28 19:58   ` Ian Romanick
2007-08-27 20:57 ` [PATCH 02/23] drm_agpsupport.c: drm_alloc + memset to drm_zalloc m.kozlowski
2007-08-27 20:57 ` [PATCH 03/23] drm_auth.c: " m.kozlowski
2007-08-27 20:57 ` [PATCH 04/23] drm_bufs.c: drm_alloc + memset to drm_alloc m.kozlowski
2007-08-27 20:57 ` [PATCH 05/23] drm_dma.c: drm_alloc + memset to drm_zalloc m.kozlowski
2007-08-27 20:57 ` [PATCH 06/23] drm_drawable.c: drm_calloc " m.kozlowski
2007-08-27 20:57 ` [PATCH 07/23] drm_fops.c: drm_alloc + memset " m.kozlowski
2007-08-27 20:57 ` [PATCH 08/23] drm_irq.c: " m.kozlowski
2007-08-27 20:57 ` [PATCH 09/23] drm_scatter.c: drm_alloc + memset to drm_alloc m.kozlowski
2007-08-27 20:58 ` [PATCH 10/23] drm_sman.c: drm_calloc to drm_zalloc m.kozlowski
2007-08-27 20:58 ` [PATCH 11/23] drm_stub.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 12/23] i810_dma.c: drm_alloc + memset " m.kozlowski
2007-08-27 20:58 ` [PATCH 13/23] i830_dma.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 14/23] i915_dma.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 15/23] i915_irq.c: drm_calloc to drm_zalloc and bugfix m.kozlowski
2007-08-27 20:58 ` [PATCH 16/23] i915_mem.c: drm_alloc + memset to drm_zalloc m.kozlowski
2007-08-27 20:58 ` [PATCH 17/23] mga_dma.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 18/23] r128_cce.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 19/23] radeon_cp.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 20/23] radeon_mem.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 21/23] savage_bci.c: drm_alloc + memset to drm_zalloc and cleanup m.kozlowski
2007-08-27 20:58 ` [PATCH 22/23] sis_drv.c: drm_calloc to drm_zalloc m.kozlowski
2007-08-27 20:58 ` [PATCH 23/23] via_map.c: " m.kozlowski
2007-08-28 20:08 ` [PATCH 00/23] drm: introduce drm_zalloc Christoph Hellwig
2007-08-28 20:50   ` Dave Airlie
2007-08-30 16:20     ` Kristian Høgsberg
2007-08-30 16:24       ` Christoph Hellwig
2007-08-30 23:20         ` Dave Airlie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox