diff options
Diffstat (limited to 'sys/dev/drm2')
-rw-r--r-- | sys/dev/drm2/drm_buffer.c | 30 | ||||
-rw-r--r-- | sys/dev/drm2/drm_crtc.c | 45 | ||||
-rw-r--r-- | sys/dev/drm2/drm_dp_iic_helper.c | 4 | ||||
-rw-r--r-- | sys/dev/drm2/drm_fb_helper.c | 2 | ||||
-rw-r--r-- | sys/dev/drm2/drm_os_freebsd.h | 28 | ||||
-rw-r--r-- | sys/dev/drm2/ttm/ttm_bo_vm.c | 33 | ||||
-rw-r--r-- | sys/dev/drm2/ttm/ttm_object.c | 5 | ||||
-rw-r--r-- | sys/dev/drm2/ttm/ttm_page_alloc.c | 2 |
8 files changed, 20 insertions, 129 deletions
diff --git a/sys/dev/drm2/drm_buffer.c b/sys/dev/drm2/drm_buffer.c index 8a674397262e..8069f2c8c4c6 100644 --- a/sys/dev/drm2/drm_buffer.c +++ b/sys/dev/drm2/drm_buffer.c @@ -50,45 +50,15 @@ int drm_buffer_alloc(struct drm_buffer **buf, int size) * variable sized */ *buf = malloc(sizeof(struct drm_buffer) + nr_pages*sizeof(char *), DRM_MEM_DRIVER, M_ZERO | M_WAITOK); - - if (*buf == NULL) { - DRM_ERROR("Failed to allocate drm buffer object to hold" - " %d bytes in %d pages.\n", - size, nr_pages); - return -ENOMEM; - } - (*buf)->size = size; for (idx = 0; idx < nr_pages; ++idx) { - (*buf)->data[idx] = malloc(min(PAGE_SIZE, size - idx * PAGE_SIZE), DRM_MEM_DRIVER, M_WAITOK); - - - if ((*buf)->data[idx] == NULL) { - DRM_ERROR("Failed to allocate %dth page for drm" - " buffer with %d bytes and %d pages.\n", - idx + 1, size, nr_pages); - goto error_out; - } - } return 0; - -error_out: - - /* Only last element can be null pointer so check for it first. */ - if ((*buf)->data[idx]) - free((*buf)->data[idx], DRM_MEM_DRIVER); - - for (--idx; idx >= 0; --idx) - free((*buf)->data[idx], DRM_MEM_DRIVER); - - free(*buf, DRM_MEM_DRIVER); - return -ENOMEM; } EXPORT_SYMBOL(drm_buffer_alloc); diff --git a/sys/dev/drm2/drm_crtc.c b/sys/dev/drm2/drm_crtc.c index b9415082e7a1..a163c7455773 100644 --- a/sys/dev/drm2/drm_crtc.c +++ b/sys/dev/drm2/drm_crtc.c @@ -662,13 +662,6 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane, plane->funcs = funcs; plane->format_types = malloc(sizeof(uint32_t) * format_count, DRM_MEM_KMS, M_WAITOK); - if (!plane->format_types) { - DRM_DEBUG_KMS("out of memory when allocating plane\n"); - drm_mode_object_put(dev, &plane->base); - ret = -ENOMEM; - goto out; - } - memcpy(plane->format_types, formats, format_count * sizeof(uint32_t)); plane->format_count = format_count; plane->possible_crtcs = possible_crtcs; @@ -725,8 +718,6 @@ struct drm_display_mode *drm_mode_create(struct drm_device *dev) nmode = malloc(sizeof(struct drm_display_mode), DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!nmode) - return NULL; if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) { free(nmode, DRM_MEM_KMS); @@ -1009,9 +1000,6 @@ int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group) group->id_list = malloc(total_objects * sizeof(uint32_t), DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!group->id_list) - return -ENOMEM; - group->num_crtcs = 0; group->num_connectors = 0; group->num_encoders = 0; @@ -1997,10 +1985,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, connector_set = malloc(crtc_req->count_connectors * sizeof(struct drm_connector *), DRM_MEM_KMS, M_WAITOK); - if (!connector_set) { - ret = -ENOMEM; - goto out; - } for (i = 0; i < crtc_req->count_connectors; i++) { set_connectors_ptr = (uint32_t __user *)(unsigned long)crtc_req->set_connectors_ptr; @@ -2522,11 +2506,6 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, } clips = malloc(num_clips * sizeof(*clips), DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!clips) { - ret = -ENOMEM; - goto out_err1; - } - ret = copy_from_user(clips, clips_ptr, num_clips * sizeof(*clips)); if (ret) { @@ -2773,15 +2752,10 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags, property = malloc(sizeof(struct drm_property), DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!property) - return NULL; - if (num_values) { + if (num_values) property->values = malloc(sizeof(uint64_t)*num_values, DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!property->values) - goto fail; - } ret = drm_mode_object_get(dev, &property->base, DRM_MODE_OBJECT_PROPERTY); if (ret) @@ -2907,9 +2881,6 @@ int drm_property_add_enum(struct drm_property *property, int index, prop_enum = malloc(sizeof(struct drm_property_enum), DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!prop_enum) - return -ENOMEM; - strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; prop_enum->value = value; @@ -3103,9 +3074,6 @@ static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev blob = malloc(sizeof(struct drm_property_blob)+length, DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!blob) - return NULL; - ret = drm_mode_object_get(dev, &blob->base, DRM_MODE_OBJECT_BLOB); if (ret) { free(blob, DRM_MEM_KMS); @@ -3433,10 +3401,6 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, crtc->gamma_store = malloc(gamma_size * sizeof(uint16_t) * 3, DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (!crtc->gamma_store) { - crtc->gamma_size = 0; - return -ENOMEM; - } return 0; } @@ -3631,13 +3595,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, mtx_unlock(&dev->event_lock); e = malloc(sizeof *e, DRM_MEM_KMS, M_WAITOK | M_ZERO); - if (e == NULL) { - mtx_lock(&dev->event_lock); - file_priv->event_space += sizeof e->event; - mtx_unlock(&dev->event_lock); - goto out; - } - e->event.base.type = DRM_EVENT_FLIP_COMPLETE; e->event.base.length = sizeof e->event; e->event.user_data = page_flip->user_data; diff --git a/sys/dev/drm2/drm_dp_iic_helper.c b/sys/dev/drm2/drm_dp_iic_helper.c index fd703494cd5e..444ceb1dcfb4 100644 --- a/sys/dev/drm2/drm_dp_iic_helper.c +++ b/sys/dev/drm2/drm_dp_iic_helper.c @@ -207,11 +207,11 @@ iic_dp_aux_attach(device_t idev) struct iic_dp_aux_data *aux_data; aux_data = device_get_softc(idev); - aux_data->port = device_add_child(idev, "iicbus", -1); + aux_data->port = device_add_child(idev, "iicbus", DEVICE_UNIT_ANY); if (aux_data->port == NULL) return (ENXIO); device_quiet(aux_data->port); - bus_generic_attach(idev); + bus_attach_children(idev); return (0); } diff --git a/sys/dev/drm2/drm_fb_helper.c b/sys/dev/drm2/drm_fb_helper.c index f67cc9f60d02..1f4abd255690 100644 --- a/sys/dev/drm2/drm_fb_helper.c +++ b/sys/dev/drm2/drm_fb_helper.c @@ -51,7 +51,7 @@ struct vt_kms_softc { struct task fb_mode_task; }; -/* Call restore out of vt(9) locks. */ +/* Call restore out of vt(4) locks. */ static void vt_restore_fbdev_mode(void *arg, int pending) { diff --git a/sys/dev/drm2/drm_os_freebsd.h b/sys/dev/drm2/drm_os_freebsd.h index 0ce0dede6d73..ec1042f8f0d4 100644 --- a/sys/dev/drm2/drm_os_freebsd.h +++ b/sys/dev/drm2/drm_os_freebsd.h @@ -154,18 +154,11 @@ typedef void irqreturn_t; #if !defined(__arm__) #if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) -#define DRM_MSG "This code is deprecated. Install the graphics/drm-kmod pkg\n" +#define DRM_MSG "WARNING! drm2 module is deprecated. Install the graphics/drm-kmod pkg\n" #else -#define DRM_MSG "This code is deprecated." +#define DRM_MSG "WARNING! drm2 module is deprecated.\n" #endif - -#define DRM_OBSOLETE(dev) \ - do { \ - device_printf(dev, "=======================================================\n"); \ - device_printf(dev, DRM_MSG); \ - device_printf(dev, "=======================================================\n"); \ - gone_in_dev(dev, 13, "drm2 drivers"); \ - } while (0) +#define DRM_OBSOLETE(dev) gone_in_dev(dev, 13, DRM_MSG) #endif /* __arm__ */ /* DRM_READMEMORYBARRIER() prevents reordering of reads. @@ -234,13 +227,6 @@ typedef void irqreturn_t; #define div_u64(n, d) ((n) / (d)) #define hweight32(i) bitcount32(i) -static inline unsigned long -roundup_pow_of_two(unsigned long x) -{ - - return (1UL << flsl(x - 1)); -} - /** * ror32 - rotate a 32-bit value right * @word: value to rotate @@ -297,13 +283,6 @@ get_unaligned_le32(const void *p) } #endif -static inline unsigned long -ilog2(unsigned long x) -{ - - return (flsl(x) - 1); -} - int64_t timeval_to_ns(const struct timeval *tv); struct timeval ns_to_timeval(const int64_t nsec); @@ -461,7 +440,6 @@ extern unsigned long drm_linux_timer_hz_mask; #define jiffies ticks #define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz) #define msecs_to_jiffies(x) (((int64_t)(x)) * hz / 1000) -#define timespec_to_jiffies(x) (((x)->tv_sec * 1000000 + (x)->tv_nsec) * hz / 1000000) #define time_after(a,b) ((long)(b) - (long)(a) < 0) #define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0) #define round_jiffies(j) ((unsigned long)(((j) + drm_linux_timer_hz_mask) & ~drm_linux_timer_hz_mask)) diff --git a/sys/dev/drm2/ttm/ttm_bo_vm.c b/sys/dev/drm2/ttm/ttm_bo_vm.c index 4f6c66382453..a30205358540 100644 --- a/sys/dev/drm2/ttm/ttm_bo_vm.c +++ b/sys/dev/drm2/ttm/ttm_bo_vm.c @@ -35,7 +35,8 @@ * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation. */ -#include <sys/cdefs.h> +#include <sys/param.h> +#include <sys/pctrie.h> #include "opt_vm.h" #include <dev/drm2/drmP.h> @@ -46,6 +47,7 @@ #include <vm/vm.h> #include <vm/vm_page.h> #include <vm/vm_pageout.h> +#include <vm/vm_radix.h> #define TTM_BO_VM_NUM_PREFAULT 16 @@ -100,7 +102,7 @@ static int ttm_bo_vm_fault(vm_object_t vm_obj, vm_ooffset_t offset, int prot, vm_page_t *mres) { - + struct pctrie_iter pages; struct ttm_buffer_object *bo = vm_obj->handle; struct ttm_bo_device *bdev = bo->bdev; struct ttm_tt *ttm = NULL; @@ -114,6 +116,7 @@ ttm_bo_vm_fault(vm_object_t vm_obj, vm_ooffset_t offset, if (*mres != NULL) { (void)vm_page_remove(*mres); } + vm_page_iter_init(&pages, vm_obj); retry: VM_OBJECT_WUNLOCK(vm_obj); m = NULL; @@ -234,10 +237,12 @@ reserve: ttm_bo_unreserve(bo); goto retry; } - m1 = vm_page_lookup(vm_obj, OFF_TO_IDX(offset)); + pctrie_iter_reset(&pages); + m1 = vm_radix_iter_lookup(&pages, OFF_TO_IDX(offset)); /* XXX This looks like it should just be vm_page_replace? */ if (m1 == NULL) { - if (vm_page_insert(m, vm_obj, OFF_TO_IDX(offset))) { + if (vm_page_iter_insert( + m, vm_obj, OFF_TO_IDX(offset), &pages) != 0) { vm_page_xunbusy(m); VM_OBJECT_WUNLOCK(vm_obj); vm_wait(vm_obj); @@ -361,26 +366,12 @@ void ttm_bo_release_mmap(struct ttm_buffer_object *bo) { vm_object_t vm_obj; - vm_page_t m; - int i; vm_obj = cdev_pager_lookup(bo); - if (vm_obj == NULL) - return; - - VM_OBJECT_WLOCK(vm_obj); -retry: - for (i = 0; i < bo->num_pages; i++) { - m = vm_page_lookup(vm_obj, i); - if (m == NULL) - continue; - if (vm_page_busy_acquire(m, VM_ALLOC_WAITFAIL) == 0) - goto retry; - cdev_pager_free_page(vm_obj, m); + if (vm_obj != NULL) { + cdev_mgtdev_pager_free_pages(vm_obj); + vm_object_deallocate(vm_obj); } - VM_OBJECT_WUNLOCK(vm_obj); - - vm_object_deallocate(vm_obj); } #if 0 diff --git a/sys/dev/drm2/ttm/ttm_object.c b/sys/dev/drm2/ttm/ttm_object.c index 8c373618d7ac..31af15cf4c56 100644 --- a/sys/dev/drm2/ttm/ttm_object.c +++ b/sys/dev/drm2/ttm/ttm_object.c @@ -282,11 +282,6 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, if (unlikely(ret != 0)) return ret; ref = malloc(sizeof(*ref), M_TTM_OBJ_REF, M_WAITOK); - if (unlikely(ref == NULL)) { - ttm_mem_global_free(mem_glob, sizeof(*ref)); - return -ENOMEM; - } - ref->hash.key = base->hash.key; ref->obj = base; ref->tfile = tfile; diff --git a/sys/dev/drm2/ttm/ttm_page_alloc.c b/sys/dev/drm2/ttm/ttm_page_alloc.c index 7518ecb4dfd1..724ba0bfb4d8 100644 --- a/sys/dev/drm2/ttm/ttm_page_alloc.c +++ b/sys/dev/drm2/ttm/ttm_page_alloc.c @@ -441,7 +441,7 @@ static int ttm_pool_get_num_unused_pages(void) /** * Callback for mm to request pool to reduce number of page held. */ -static int ttm_pool_mm_shrink(void *arg) +static int ttm_pool_mm_shrink(void *arg, int flags __unused) { static unsigned int start_pool = 0; unsigned i; |