summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drm_crtc.c69
-rw-r--r--sys/dev/pci/drm/drm_crtc_helper.c32
-rw-r--r--sys/dev/pci/drm/drm_edid.c6
-rw-r--r--sys/dev/pci/drm/drm_fb_helper.c56
-rw-r--r--sys/dev/pci/drm/drm_global.c4
-rw-r--r--sys/dev/pci/drm/drm_hashtab.c6
-rw-r--r--sys/dev/pci/drm/drm_irq.c51
-rw-r--r--sys/dev/pci/drm/drm_mm.c14
8 files changed, 110 insertions, 128 deletions
diff --git a/sys/dev/pci/drm/drm_crtc.c b/sys/dev/pci/drm/drm_crtc.c
index e4d03e8d694..f8e1b676f09 100644
--- a/sys/dev/pci/drm/drm_crtc.c
+++ b/sys/dev/pci/drm/drm_crtc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_crtc.c,v 1.7 2014/02/13 12:33:08 kettenis Exp $ */
+/* $OpenBSD: drm_crtc.c,v 1.8 2014/03/09 11:07:18 jsg Exp $ */
/*
* Copyright (c) 2006-2008 Intel Corporation
* Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
@@ -492,10 +492,8 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
- if (crtc->gamma_store) {
- free(crtc->gamma_store, M_DRM);
- crtc->gamma_store = NULL;
- }
+ kfree(crtc->gamma_store);
+ crtc->gamma_store = NULL;
drm_mode_object_put(dev, &crtc->base);
list_del(&crtc->head);
@@ -695,8 +693,8 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
plane->base.properties = &plane->properties;
plane->dev = dev;
plane->funcs = funcs;
- plane->format_types = malloc(sizeof(uint32_t) * format_count,
- M_DRM, M_WAITOK);
+ plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
+ GFP_KERNEL);
if (!plane->format_types) {
DRM_DEBUG_KMS("out of memory when allocating plane\n");
@@ -732,7 +730,7 @@ void drm_plane_cleanup(struct drm_plane *plane)
struct drm_device *dev = plane->dev;
rw_enter_write(&dev->mode_config.rwl);
- free(plane->format_types, M_DRM);
+ kfree(plane->format_types);
drm_mode_object_put(dev, &plane->base);
/* if not added to a list, it must be a private plane */
if (!list_empty(&plane->head)) {
@@ -759,12 +757,12 @@ struct drm_display_mode *drm_mode_create(struct drm_device *dev)
{
struct drm_display_mode *nmode;
- nmode = malloc(sizeof(struct drm_display_mode), M_DRM, M_WAITOK|M_ZERO);
+ nmode = kzalloc(sizeof(struct drm_display_mode), GFP_KERNEL);
if (!nmode)
return NULL;
if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) {
- free(nmode, M_DRM);
+ kfree(nmode);
return NULL;
}
@@ -789,7 +787,7 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
drm_mode_object_put(dev, &mode->base);
- free(mode, M_DRM);
+ kfree(mode);
}
EXPORT_SYMBOL(drm_mode_destroy);
@@ -1043,8 +1041,7 @@ int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group)
total_objects += dev->mode_config.num_connector;
total_objects += dev->mode_config.num_encoder;
- group->id_list = malloc(total_objects * sizeof(uint32_t),
- M_DRM, M_WAITOK|M_ZERO);
+ group->id_list = kzalloc(total_objects * sizeof(uint32_t), GFP_KERNEL);
if (!group->id_list)
return -ENOMEM;
@@ -2046,9 +2043,9 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
goto out;
}
- connector_set = malloc(crtc_req->count_connectors *
+ connector_set = kmalloc(crtc_req->count_connectors *
sizeof(struct drm_connector *),
- M_DRM, M_WAITOK);
+ GFP_KERNEL);
if (!connector_set) {
ret = -ENOMEM;
goto out;
@@ -2089,8 +2086,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
ret = crtc->funcs->set_config(&set);
out:
- if (connector_set != NULL)
- free(connector_set, M_DRM);
+ kfree(connector_set);
drm_mode_destroy(dev, mode);
rw_exit_write(&dev->mode_config.rwl);
return ret;
@@ -2575,8 +2571,7 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
ret = -EINVAL;
goto out_err1;
}
- clips = malloc(num_clips * sizeof(*clips), M_DRM,
- M_WAITOK|M_ZERO);
+ clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL);
if (!clips) {
ret = -ENOMEM;
goto out_err1;
@@ -2600,7 +2595,7 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
}
out_err2:
- free(clips, M_DRM);
+ kfree(clips);
out_err1:
rw_exit_write(&dev->mode_config.rwl);
return ret;
@@ -2826,13 +2821,12 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
struct drm_property *property = NULL;
int ret;
- property = malloc(sizeof(struct drm_property), M_DRM, M_WAITOK|M_ZERO);
+ property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
if (!property)
return NULL;
if (num_values) {
- property->values = malloc(sizeof(uint64_t)*num_values,
- M_DRM, M_WAITOK|M_ZERO);
+ property->values = kzalloc(sizeof(uint64_t)*num_values, GFP_KERNEL);
if (!property->values)
goto fail;
}
@@ -2853,8 +2847,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
list_add_tail(&property->head, &dev->mode_config.property_list);
return property;
fail:
- free(property->values, M_DRM);
- free(property, M_DRM);
+ kfree(property->values);
+ kfree(property);
return NULL;
}
EXPORT_SYMBOL(drm_property_create);
@@ -2959,8 +2953,7 @@ int drm_property_add_enum(struct drm_property *property, int index,
}
}
- prop_enum = malloc(sizeof(struct drm_property_enum), M_DRM,
- M_WAITOK | M_ZERO);
+ prop_enum = kzalloc(sizeof(struct drm_property_enum), GFP_KERNEL);
if (!prop_enum)
return -ENOMEM;
@@ -2980,14 +2973,14 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property)
list_for_each_entry_safe(prop_enum, pt, &property->enum_blob_list, head) {
list_del(&prop_enum->head);
- free(prop_enum, M_DRM);
+ kfree(prop_enum);
}
if (property->num_values)
- free(property->values, M_DRM);
+ kfree(property->values);
drm_mode_object_put(dev, &property->base);
list_del(&property->head);
- free(property, M_DRM);
+ kfree(property);
}
EXPORT_SYMBOL(drm_property_destroy);
@@ -3162,14 +3155,13 @@ static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev
if (!length || !data)
return NULL;
- blob = malloc(sizeof(struct drm_property_blob)+length,
- M_DRM, M_WAITOK|M_ZERO);
+ blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
if (!blob)
return NULL;
ret = drm_mode_object_get(dev, &blob->base, DRM_MODE_OBJECT_BLOB);
if (ret) {
- free(blob, M_DRM);
+ kfree(blob);
return NULL;
}
@@ -3186,7 +3178,7 @@ static void drm_property_destroy_blob(struct drm_device *dev,
{
drm_mode_object_put(dev, &blob->base);
list_del(&blob->head);
- free(blob, M_DRM);
+ kfree(blob);
}
int drm_mode_getblob_ioctl(struct drm_device *dev,
@@ -3494,8 +3486,7 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
{
crtc->gamma_size = gamma_size;
- crtc->gamma_store = malloc(gamma_size * sizeof(uint16_t) * 3,
- M_DRM, M_WAITOK|M_ZERO);
+ crtc->gamma_store = kzalloc(gamma_size * sizeof(uint16_t) * 3, GFP_KERNEL);
if (!crtc->gamma_store) {
crtc->gamma_size = 0;
return -ENOMEM;
@@ -3692,7 +3683,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
file_priv->event_space -= sizeof e->event;
mtx_leave(&dev->event_lock);
- e = malloc(sizeof *e, M_DRM, M_WAITOK|M_ZERO);
+ e = kzalloc(sizeof *e, GFP_KERNEL);
if (e == NULL) {
mtx_enter(&dev->event_lock);
file_priv->event_space += sizeof e->event;
@@ -3706,7 +3697,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
e->base.event = &e->event.base;
e->base.file_priv = file_priv;
e->base.destroy =
- (void (*) (struct drm_pending_event *)) drm_free;
+ (void (*) (struct drm_pending_event *)) kfree;
}
ret = crtc->funcs->page_flip(crtc, fb, e);
@@ -3715,7 +3706,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
mtx_enter(&dev->event_lock);
file_priv->event_space += sizeof e->event;
mtx_leave(&dev->event_lock);
- free(e, M_DRM);
+ kfree(e);
}
}
diff --git a/sys/dev/pci/drm/drm_crtc_helper.c b/sys/dev/pci/drm/drm_crtc_helper.c
index 6bcf30cc111..4f740463494 100644
--- a/sys/dev/pci/drm/drm_crtc_helper.c
+++ b/sys/dev/pci/drm/drm_crtc_helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_crtc_helper.c,v 1.6 2013/12/16 19:57:09 kettenis Exp $ */
+/* $OpenBSD: drm_crtc_helper.c,v 1.7 2014/03/09 11:07:18 jsg Exp $ */
/*
* Copyright (c) 2006-2008 Intel Corporation
* Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
@@ -587,23 +587,23 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
/* Allocate space for the backup of all (non-pointer) crtc, encoder and
* connector data. */
- save_crtcs = malloc(dev->mode_config.num_crtc *
- sizeof(struct drm_crtc), M_DRM, M_WAITOK|M_ZERO);
+ save_crtcs = kzalloc(dev->mode_config.num_crtc *
+ sizeof(struct drm_crtc), GFP_KERNEL);
if (!save_crtcs)
return -ENOMEM;
- save_encoders = malloc(dev->mode_config.num_encoder *
- sizeof(struct drm_encoder), M_DRM, M_WAITOK|M_ZERO);
+ save_encoders = kzalloc(dev->mode_config.num_encoder *
+ sizeof(struct drm_encoder), GFP_KERNEL);
if (!save_encoders) {
- free(save_crtcs, M_DRM);
+ kfree(save_crtcs);
return -ENOMEM;
}
- save_connectors = malloc(dev->mode_config.num_connector *
- sizeof(struct drm_connector), M_DRM, M_WAITOK|M_ZERO);
+ save_connectors = kzalloc(dev->mode_config.num_connector *
+ sizeof(struct drm_connector), GFP_KERNEL);
if (!save_connectors) {
- free(save_crtcs, M_DRM);
- free(save_encoders, M_DRM);
+ kfree(save_crtcs);
+ kfree(save_encoders);
return -ENOMEM;
}
@@ -775,9 +775,9 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
}
}
- free(save_connectors, M_DRM);
- free(save_encoders, M_DRM);
- free(save_crtcs, M_DRM);
+ kfree(save_connectors);
+ kfree(save_encoders);
+ kfree(save_crtcs);
return 0;
fail:
@@ -803,9 +803,9 @@ fail:
save_set.y, save_set.fb))
DRM_ERROR("failed to restore config after modeset failure\n");
- free(save_connectors, M_DRM);
- free(save_encoders, M_DRM);
- free(save_crtcs, M_DRM);
+ kfree(save_connectors);
+ kfree(save_encoders);
+ kfree(save_crtcs);
return ret;
}
EXPORT_SYMBOL(drm_crtc_helper_set_config);
diff --git a/sys/dev/pci/drm/drm_edid.c b/sys/dev/pci/drm/drm_edid.c
index 2f27bdef94c..cf490941d16 100644
--- a/sys/dev/pci/drm/drm_edid.c
+++ b/sys/dev/pci/drm/drm_edid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_edid.c,v 1.8 2014/01/22 22:41:48 jsg Exp $ */
+/* $OpenBSD: drm_edid.c,v 1.9 2014/03/09 11:07:18 jsg Exp $ */
/*
* Copyright (c) 2006 Luc Verhaegen (quirks list)
* Copyright (c) 2007-2008 Intel Corporation
@@ -304,7 +304,7 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_controller *adapter)
u8 *block, *new;
bool print_bad_edid = !connector->bad_edid_counter;
- if ((block = malloc(EDID_LENGTH, M_DRM, M_WAITOK)) == NULL)
+ if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
return NULL;
/* base block fetch */
@@ -374,7 +374,7 @@ carp:
connector->bad_edid_counter++;
out:
- free(block, M_DRM);
+ kfree(block);
return NULL;
}
diff --git a/sys/dev/pci/drm/drm_fb_helper.c b/sys/dev/pci/drm/drm_fb_helper.c
index 67c03a69fb3..57e53cb149e 100644
--- a/sys/dev/pci/drm/drm_fb_helper.c
+++ b/sys/dev/pci/drm/drm_fb_helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_fb_helper.c,v 1.5 2013/09/02 06:25:28 jsg Exp $ */
+/* $OpenBSD: drm_fb_helper.c,v 1.6 2014/03/09 11:07:18 jsg Exp $ */
/*
* Copyright (c) 2006-2009 Red Hat Inc.
* Copyright (c) 2006-2008 Intel Corporation
@@ -56,8 +56,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
struct drm_fb_helper_connector *fb_helper_connector;
- fb_helper_connector = malloc(sizeof(struct drm_fb_helper_connector), M_DRM,
- M_WAITOK | M_ZERO);
+ fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL);
if (!fb_helper_connector)
goto fail;
@@ -67,7 +66,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
return 0;
fail:
for (i = 0; i < fb_helper->connector_count; i++) {
- free(fb_helper->connector_info[i], M_DRM);
+ kfree(fb_helper->connector_info[i]);
fb_helper->connector_info[i] = NULL;
}
fb_helper->connector_count = 0;
@@ -388,14 +387,14 @@ static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
int i;
for (i = 0; i < helper->connector_count; i++)
- free(helper->connector_info[i], M_DRM);
- free(helper->connector_info, M_DRM);
+ kfree(helper->connector_info[i]);
+ kfree(helper->connector_info);
for (i = 0; i < helper->crtc_count; i++) {
- free(helper->crtc_info[i].mode_set.connectors, M_DRM);
+ kfree(helper->crtc_info[i].mode_set.connectors);
if (helper->crtc_info[i].mode_set.mode)
drm_mode_destroy(helper->dev, helper->crtc_info[i].mode_set.mode);
}
- free(helper->crtc_info, M_DRM);
+ kfree(helper->crtc_info);
}
int drm_fb_helper_init(struct drm_device *dev,
@@ -409,25 +408,23 @@ int drm_fb_helper_init(struct drm_device *dev,
INIT_LIST_HEAD(&fb_helper->kernel_fb_list);
- fb_helper->crtc_info = malloc(crtc_count *
- sizeof(struct drm_fb_helper_crtc), M_DRM, M_WAITOK | M_ZERO);
+ fb_helper->crtc_info = kcalloc(crtc_count, sizeof(struct drm_fb_helper_crtc), GFP_KERNEL);
if (!fb_helper->crtc_info)
return -ENOMEM;
fb_helper->crtc_count = crtc_count;
- fb_helper->connector_info = malloc(dev->mode_config.num_connector *
- sizeof(struct drm_fb_helper_connector *), M_DRM,
- M_WAITOK | M_ZERO);
+ fb_helper->connector_info = kcalloc(dev->mode_config.num_connector, sizeof(struct drm_fb_helper_connector *), GFP_KERNEL);
if (!fb_helper->connector_info) {
- free(fb_helper->crtc_info, M_DRM);
+ kfree(fb_helper->crtc_info);
return -ENOMEM;
}
fb_helper->connector_count = 0;
for (i = 0; i < crtc_count; i++) {
fb_helper->crtc_info[i].mode_set.connectors =
- malloc(max_conn_count * sizeof(struct drm_connector *),
- M_DRM, M_WAITOK | M_ZERO);
+ kcalloc(max_conn_count,
+ sizeof(struct drm_connector *),
+ GFP_KERNEL);
if (!fb_helper->crtc_info[i].mode_set.connectors)
goto out_free;
@@ -1205,9 +1202,8 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
if (modes[n] == NULL)
return best_score;
- crtcs = malloc(dev->mode_config.num_connector *
- sizeof(struct drm_fb_helper_crtc *), M_DRM,
- M_WAITOK | M_ZERO);
+ crtcs = kzalloc(dev->mode_config.num_connector *
+ sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
if (!crtcs)
return best_score;
@@ -1258,7 +1254,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
}
}
out:
- free(crtcs, M_DRM);
+ kfree(crtcs);
return best_score;
}
@@ -1277,14 +1273,12 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
width = dev->mode_config.max_width;
height = dev->mode_config.max_height;
- crtcs = malloc(dev->mode_config.num_connector *
- sizeof(struct drm_fb_helper_crtc *), M_DRM,
- M_WAITOK | M_ZERO);
- modes = malloc(dev->mode_config.num_connector *
- sizeof(struct drm_display_mode *), M_DRM,
- M_WAITOK | M_ZERO);
- enabled = malloc(dev->mode_config.num_connector *
- sizeof(bool), M_DRM, M_WAITOK | M_ZERO);
+ crtcs = kcalloc(dev->mode_config.num_connector,
+ sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
+ modes = kcalloc(dev->mode_config.num_connector,
+ sizeof(struct drm_display_mode *), GFP_KERNEL);
+ enabled = kcalloc(dev->mode_config.num_connector,
+ sizeof(bool), GFP_KERNEL);
if (!crtcs || !modes || !enabled) {
DRM_ERROR("Memory allocation failed\n");
goto out;
@@ -1329,9 +1323,9 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
}
out:
- free(crtcs, M_DRM);
- free(modes, M_DRM);
- free(enabled, M_DRM);
+ kfree(crtcs);
+ kfree(modes);
+ kfree(enabled);
}
/**
diff --git a/sys/dev/pci/drm/drm_global.c b/sys/dev/pci/drm/drm_global.c
index 0f2f8877e28..3b9c4867b28 100644
--- a/sys/dev/pci/drm/drm_global.c
+++ b/sys/dev/pci/drm/drm_global.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_global.c,v 1.1 2013/08/12 04:11:52 jsg Exp $ */
+/* $OpenBSD: drm_global.c,v 1.2 2014/03/09 11:07:18 jsg Exp $ */
/**************************************************************************
*
* Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
@@ -71,7 +71,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
rw_enter_write(&item->rwlock);
if (item->refcount == 0) {
- item->object = malloc(ref->size, M_DRM, M_WAITOK | M_ZERO);
+ item->object = kzalloc(ref->size, GFP_KERNEL);
if (unlikely(item->object == NULL)) {
ret = -ENOMEM;
goto out_err;
diff --git a/sys/dev/pci/drm/drm_hashtab.c b/sys/dev/pci/drm/drm_hashtab.c
index 77f321ef0a3..25440033025 100644
--- a/sys/dev/pci/drm/drm_hashtab.c
+++ b/sys/dev/pci/drm/drm_hashtab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_hashtab.c,v 1.1 2013/08/12 04:11:52 jsg Exp $ */
+/* $OpenBSD: drm_hashtab.c,v 1.2 2014/03/09 11:07:18 jsg Exp $ */
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
@@ -51,7 +51,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
ht->order = order;
ht->table = NULL;
if (size <= PAGE_SIZE / sizeof(*ht->table))
- ht->table = drm_calloc(size, sizeof(*ht->table));
+ ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL);
else
ht->table = vzalloc(size*sizeof(*ht->table));
if (!ht->table) {
@@ -244,7 +244,7 @@ void drm_ht_remove(struct drm_open_hash *ht)
#ifdef notyet
if (ht->table) {
if ((PAGE_SIZE / sizeof(*ht->table)) >> ht->order)
- free(ht->table, M_DRM);
+ kfree(ht->table);
else
vfree(ht->table);
ht->table = NULL;
diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c
index 1cb8f517026..b7dd919b1ef 100644
--- a/sys/dev/pci/drm/drm_irq.c
+++ b/sys/dev/pci/drm/drm_irq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_irq.c,v 1.53 2014/01/24 04:43:56 jsg Exp $ */
+/* $OpenBSD: drm_irq.c,v 1.54 2014/03/09 11:07:18 jsg Exp $ */
/**
* \file drm_irq.c
* IRQ support
@@ -251,14 +251,14 @@ void drm_vblank_cleanup(struct drm_device *dev)
vblank_disable_fn(dev);
- free(dev->vbl_queue, M_DRM);
- free(dev->_vblank_count, M_DRM);
- free(dev->vblank_refcount, M_DRM);
- free(dev->vblank_enabled, M_DRM);
- free(dev->last_vblank, M_DRM);
- free(dev->last_vblank_wait, M_DRM);
- free(dev->vblank_inmodeset, M_DRM);
- free(dev->_vblank_time, M_DRM);
+ kfree(dev->vbl_queue);
+ kfree(dev->_vblank_count);
+ kfree(dev->vblank_refcount);
+ kfree(dev->vblank_enabled);
+ kfree(dev->last_vblank);
+ kfree(dev->last_vblank_wait);
+ kfree(dev->vblank_inmodeset);
+ kfree(dev->_vblank_time);
dev->num_crtcs = 0;
}
@@ -275,43 +275,38 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
dev->num_crtcs = num_crtcs;
- dev->vbl_queue = malloc(sizeof(int) * num_crtcs,
- M_DRM, M_WAITOK);
+ dev->vbl_queue = kmalloc(sizeof(int) * num_crtcs,
+ GFP_KERNEL);
if (!dev->vbl_queue)
goto err;
- dev->_vblank_count = malloc(sizeof(atomic_t) * num_crtcs,
- M_DRM, M_WAITOK);
+ dev->_vblank_count = kmalloc(sizeof(atomic_t) * num_crtcs, GFP_KERNEL);
if (!dev->_vblank_count)
goto err;
- dev->vblank_refcount = malloc(sizeof(atomic_t) * num_crtcs,
- M_DRM, M_WAITOK);
+ dev->vblank_refcount = kmalloc(sizeof(atomic_t) * num_crtcs,
+ GFP_KERNEL);
if (!dev->vblank_refcount)
goto err;
- dev->vblank_enabled = malloc(num_crtcs * sizeof(int),
- M_DRM, M_ZERO | M_WAITOK);
+ dev->vblank_enabled = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
if (!dev->vblank_enabled)
goto err;
- dev->last_vblank = malloc(num_crtcs * sizeof(u32),
- M_DRM, M_ZERO | M_WAITOK);
+ dev->last_vblank = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
if (!dev->last_vblank)
goto err;
- dev->last_vblank_wait = malloc(num_crtcs * sizeof(u32),
- M_DRM, M_ZERO | M_WAITOK);
+ dev->last_vblank_wait = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
if (!dev->last_vblank_wait)
goto err;
- dev->vblank_inmodeset = malloc(num_crtcs * sizeof(int),
- M_DRM, M_ZERO | M_WAITOK);
+ dev->vblank_inmodeset = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
if (!dev->vblank_inmodeset)
goto err;
- dev->_vblank_time = malloc(num_crtcs * DRM_VBLANKTIME_RBSIZE *
- sizeof(struct timeval), M_DRM, M_ZERO | M_WAITOK);
+ dev->_vblank_time = kcalloc(num_crtcs * DRM_VBLANKTIME_RBSIZE,
+ sizeof(struct timeval), GFP_KERNEL);
if (!dev->_vblank_time)
goto err;
@@ -1164,7 +1159,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
unsigned int seq;
int ret;
- e = malloc(sizeof *e, M_DRM, M_ZERO | M_WAITOK);
+ e = kzalloc(sizeof *e, GFP_KERNEL);
if (e == NULL) {
ret = -ENOMEM;
goto err_put;
@@ -1177,7 +1172,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
e->event.user_data = vblwait->request.signal;
e->base.event = &e->event.base;
e->base.file_priv = file_priv;
- e->base.destroy = (void (*) (struct drm_pending_event *)) drm_free;
+ e->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
mtx_enter(&dev->event_lock);
@@ -1220,7 +1215,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
err_unlock:
mtx_leave(&dev->event_lock);
- free(e, M_DRM);
+ kfree(e);
err_put:
drm_vblank_put(dev, pipe);
return ret;
diff --git a/sys/dev/pci/drm/drm_mm.c b/sys/dev/pci/drm/drm_mm.c
index de8dc64350d..190ce15b206 100644
--- a/sys/dev/pci/drm/drm_mm.c
+++ b/sys/dev/pci/drm/drm_mm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_mm.c,v 1.3 2014/02/15 10:03:15 jsg Exp $ */
+/* $OpenBSD: drm_mm.c,v 1.4 2014/03/09 11:07:18 jsg Exp $ */
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA.
@@ -51,8 +51,10 @@ static struct drm_mm_node *drm_mm_kmalloc(struct drm_mm *mm, int atomic)
{
struct drm_mm_node *child;
- child = malloc(sizeof(*child), M_DRM, M_ZERO |
- (atomic ? M_NOWAIT : M_WAITOK));
+ if (atomic)
+ child = kzalloc(sizeof(*child), GFP_ATOMIC);
+ else
+ child = kzalloc(sizeof(*child), GFP_KERNEL);
if (unlikely(child == NULL)) {
mtx_enter(&mm->unused_lock);
@@ -82,7 +84,7 @@ int drm_mm_pre_get(struct drm_mm *mm)
mtx_enter(&mm->unused_lock);
while (mm->num_unused < MM_UNUSED_TARGET) {
mtx_leave(&mm->unused_lock);
- node = malloc(sizeof(*node), M_DRM, M_WAITOK);
+ node = kzalloc(sizeof(*node), GFP_KERNEL);
mtx_enter(&mm->unused_lock);
if (unlikely(node == NULL)) {
@@ -358,7 +360,7 @@ void drm_mm_put_block(struct drm_mm_node *node)
list_add(&node->node_list, &mm->unused_nodes);
++mm->num_unused;
} else
- free(node, M_DRM);
+ kfree(node);
mtx_leave(&mm->unused_lock);
}
EXPORT_SYMBOL(drm_mm_put_block);
@@ -673,7 +675,7 @@ void drm_mm_takedown(struct drm_mm * mm)
mtx_enter(&mm->unused_lock);
list_for_each_entry_safe(entry, next, &mm->unused_nodes, node_list) {
list_del(&entry->node_list);
- free(entry, M_DRM);
+ kfree(entry);
--mm->num_unused;
}
mtx_leave(&mm->unused_lock);