diff options
-rw-r--r-- | linux-core/drm_bufs.c | 18 | ||||
-rw-r--r-- | linux-core/drm_hashtab.c | 6 | ||||
-rw-r--r-- | linux-core/drm_vm.c | 2 | ||||
-rw-r--r-- | linux-core/via_dmablit.c | 6 | ||||
-rw-r--r-- | shared-core/radeon_state.c | 25 | ||||
-rw-r--r-- | shared-core/via_drm.h | 12 | ||||
-rw-r--r-- | shared-core/via_irq.c | 2 |
7 files changed, 36 insertions, 35 deletions
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 7d3121d3..abd7c829 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -65,7 +65,7 @@ static drm_map_list_t *drm_find_matching_map(drm_device_t *dev, return NULL; } -static int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, +static int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, unsigned long user_token, int hashed_handle) { int use_hashed_handle; @@ -78,14 +78,16 @@ static int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, #error Unsupported long size. Neither 64 nor 32 bits. #endif - if (use_hashed_handle) { - return drm_ht_just_insert_please(&dev->map_hash, hash, - user_token, 32 - PAGE_SHIFT - 3, - PAGE_SHIFT, DRM_MAP_HASH_OFFSET); - } else { + if (!use_hashed_handle) { + int ret; hash->key = user_token; - return drm_ht_insert_item(&dev->map_hash, hash); + ret = drm_ht_insert_item(&dev->map_hash, hash); + if (ret != -EINVAL) + return ret; } + return drm_ht_just_insert_please(&dev->map_hash, hash, + user_token, 32 - PAGE_SHIFT - 3, + PAGE_SHIFT, DRM_MAP_HASH_OFFSET); } /** @@ -290,7 +292,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, user_token = (map->type == _DRM_SHM) ? (unsigned long) map->handle : map->offset; - ret = drm_map_handle(dev, &list->hash, user_token, 0); + ret = drm_map_handle(dev, &list->hash, user_token, 0); if (ret) { drm_free(map, sizeof(*map), DRM_MEM_MAPS); diff --git a/linux-core/drm_hashtab.c b/linux-core/drm_hashtab.c index 48061139..a0b2d680 100644 --- a/linux-core/drm_hashtab.c +++ b/linux-core/drm_hashtab.c @@ -106,7 +106,7 @@ int drm_ht_insert_item(drm_open_hash_t *ht, drm_hash_item_t *item) hlist_for_each(list, h_list) { entry = hlist_entry(list, drm_hash_item_t, head); if (entry->key == key) - return -1; + return -EINVAL; if (entry->key > key) break; parent = list; @@ -154,7 +154,7 @@ int drm_ht_find_item(drm_open_hash_t *ht, unsigned long key, list = drm_ht_find_key(ht, key); if (!list) - return -1; + return -EINVAL; *item = hlist_entry(list, drm_hash_item_t, head); return 0; @@ -170,7 +170,7 @@ int drm_ht_remove_key(drm_open_hash_t *ht, unsigned long key) ht->fill--; return 0; } - return -1; + return -EINVAL; } int drm_ht_remove_item(drm_open_hash_t *ht, drm_hash_item_t *item) diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 0391395d..9672269a 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -70,7 +70,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, if (!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error; - if (drm_ht_find_item(&dev->map_hash, VM_OFFSET(vma), &hash)) + if (drm_ht_find_item(&dev->map_hash, VM_OFFSET(vma), &hash)) goto vm_nopage_error; r_list = drm_hash_entry(hash, drm_map_list_t, hash); diff --git a/linux-core/via_dmablit.c b/linux-core/via_dmablit.c index 61e6a102..fdc2bd67 100644 --- a/linux-core/via_dmablit.c +++ b/linux-core/via_dmablit.c @@ -125,10 +125,10 @@ via_map_blit_for_device(struct pci_dev *pdev, line_len -= remaining_len; if (mode == 1) { - desc_ptr->mem_addr = dma_map_page(&pdev->dev, - vsg->pages[VIA_PFN(cur_mem) - + desc_ptr->mem_addr = dma_map_page(&pdev->dev, + vsg->pages[VIA_PFN(cur_mem) - VIA_PFN(first_addr)], - VIA_PGOFF(cur_mem), remaining_len, + VIA_PGOFF(cur_mem), remaining_len, vsg->direction); desc_ptr->dev_addr = cur_fb; diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c index 99672fa7..8c1a4065 100644 --- a/shared-core/radeon_state.c +++ b/shared-core/radeon_state.c @@ -42,7 +42,11 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t * drm_file_t * filp_priv, u32 * offset) { - u32 off = *offset; + u64 off = *offset; + u32 fb_start = dev_priv->fb_location; + u32 fb_end = fb_start + dev_priv->fb_size - 1; + u32 gart_start = dev_priv->gart_vm_start; + u32 gart_end = gart_start + dev_priv->gart_size - 1; struct drm_radeon_driver_file_fields *radeon_priv; /* Hrm ... the story of the offset ... So this function converts @@ -62,10 +66,8 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t * /* First, the best case, the offset already lands in either the * framebuffer or the GART mapped space */ - if ((off >= dev_priv->fb_location && - off < (dev_priv->fb_location + dev_priv->fb_size)) || - (off >= dev_priv->gart_vm_start && - off < (dev_priv->gart_vm_start + dev_priv->gart_size))) + if ((off >= fb_start && off <= fb_end) || + (off >= gart_start && off <= gart_end)) return 0; /* Ok, that didn't happen... now check if we have a zero based @@ -78,16 +80,13 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t * } /* Finally, assume we aimed at a GART offset if beyond the fb */ - if (off > (dev_priv->fb_location + dev_priv->fb_size)) - off = off - (dev_priv->fb_location + dev_priv->fb_size) + - dev_priv->gart_vm_start; + if (off > fb_end) + off = off - fb_end - 1 + gart_start; /* Now recheck and fail if out of bounds */ - if ((off >= dev_priv->fb_location && - off < (dev_priv->fb_location + dev_priv->fb_size)) || - (off >= dev_priv->gart_vm_start && - off < (dev_priv->gart_vm_start + dev_priv->gart_size))) { - DRM_DEBUG("offset fixed up to 0x%x\n", off); + if ((off >= fb_start && off <= fb_end) || + (off >= gart_start && off <= gart_end)) { + DRM_DEBUG("offset fixed up to 0x%x\n", (unsigned int)off); *offset = off; return 0; } diff --git a/shared-core/via_drm.h b/shared-core/via_drm.h index 60fb92c8..ee92ff69 100644 --- a/shared-core/via_drm.h +++ b/shared-core/via_drm.h @@ -273,14 +273,14 @@ typedef struct drm_via_blitsync { */ typedef struct drm_via_dmablit { - uint32_t num_lines; - uint32_t line_length; + uint32_t num_lines; + uint32_t line_length; - uint32_t fb_addr; - uint32_t fb_stride; + uint32_t fb_addr; + uint32_t fb_stride; - unsigned char *mem_addr; - uint32_t mem_stride; + unsigned char *mem_addr; + uint32_t mem_stride; uint32_t flags; int to_fb; diff --git a/shared-core/via_irq.c b/shared-core/via_irq.c index 1862fbcf..db60b28e 100644 --- a/shared-core/via_irq.c +++ b/shared-core/via_irq.c @@ -198,7 +198,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence) return ret; } -static int +static int via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, unsigned int *sequence) { |