Merge remote branch 'origin/master' into modesetting-101

Conflicts:

	linux-core/drm_compat.c
main
Dave Airlie 2008-03-05 10:37:02 +10:00
commit 43891ff2d0
10 changed files with 122 additions and 38 deletions

View File

@ -2806,23 +2806,18 @@ int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
} }
return 0; return 0;
} }
int drmBOBusy(int fd, drmBO *buf, int *busy) int drmBOBusy(int fd, drmBO *buf, int *busy)
{ {
if (!(buf->flags & DRM_BO_FLAG_SHAREABLE) && int ret = drmBOInfo(fd, buf);
!(buf->replyFlags & DRM_BO_REP_BUSY)) {
*busy = 0; if (ret)
return 0; return ret;
}
else { *busy = (buf->replyFlags & DRM_BO_REP_BUSY);
int ret = drmBOInfo(fd, buf); return 0;
if (ret)
return ret;
*busy = (buf->replyFlags & DRM_BO_REP_BUSY);
return 0;
}
} }
int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize, int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
unsigned memType) unsigned memType)
{ {

View File

@ -666,7 +666,7 @@ void drm_agp_chipset_flush(struct drm_device *dev)
{ {
agp_flush_chipset(dev->agp->bridge); agp_flush_chipset(dev->agp->bridge);
} }
EXPORT_SYMBOL(drm_agp_flush_chipset); EXPORT_SYMBOL(drm_agp_chipset_flush);
#endif #endif
#endif /* __OS_HAS_AGP */ #endif /* __OS_HAS_AGP */

View File

@ -596,3 +596,36 @@ void drm_bo_kunmap(struct drm_bo_kmap_obj *map)
map->page = NULL; map->page = NULL;
} }
EXPORT_SYMBOL(drm_bo_kunmap); EXPORT_SYMBOL(drm_bo_kunmap);
int drm_bo_pfn_prot(struct drm_buffer_object *bo,
unsigned long dst_offset,
unsigned long *pfn,
pgprot_t *prot)
{
struct drm_bo_mem_reg *mem = &bo->mem;
struct drm_device *dev = bo->dev;
unsigned long bus_offset;
unsigned long bus_size;
unsigned long bus_base;
struct drm_mem_type_manager *man = &dev->bm.man[mem->mem_type];
int ret;
ret = drm_bo_pci_offset(dev, mem, &bus_base, &bus_offset,
&bus_size);
if (ret)
return -EINVAL;
if (bus_size != 0)
*pfn = (bus_base + bus_offset + dst_offset) >> PAGE_SHIFT;
else if (!bo->ttm)
return -EINVAL;
else
*pfn = page_to_pfn(drm_ttm_get_page(bo->ttm, dst_offset >> PAGE_SHIFT));
*prot = (mem->flags & DRM_BO_FLAG_CACHED) ?
PAGE_KERNEL : drm_kernel_io_prot(man->drm_bus_maptype);
return 0;
}
EXPORT_SYMBOL(drm_bo_pfn_prot);

View File

@ -779,3 +779,32 @@ struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn)
} }
EXPORT_SYMBOL(pci_get_bus_and_slot); EXPORT_SYMBOL(pci_get_bus_and_slot);
#endif #endif
#if defined(DRM_KMAP_ATOMIC_PROT_PFN) && defined(CONFIG_HIMEM)
#define drm_kmap_get_fixmap_pte(vaddr) \
pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), vaddr), (vaddr)), (vaddr))
void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type,
pgprot_t protection)
{
enum fixed_addresses idx;
unsigned long vaddr;
static pte_t *km_pte;
static int initialized = 0;
if (unlikely(!initialized)) {
km_pte = drm_kmap_get_fixmap_pte(__fix_to_virt(FIX_KMAP_BEGIN));
initialized = 1;
}
pagefault_disable();
idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
set_pte(km_pte-idx, pfn_pte(pfn, protection));
return (void*) vaddr;
}
EXPORT_SYMBOL(kmap_atomic_prot_pfn);

View File

@ -343,4 +343,9 @@ extern struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devf
#define PM_EVENT_PRETHAW 3 #define PM_EVENT_PRETHAW 3
#endif #endif
#if (defined(CONFIG_X86) && defined(CONFIG_X86_32) && defined(CONFIG_HIMEM))
#define DRM_KMAP_ATOMIC_PROT_PFN
extern void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type,
pgprot_t protection);
#endif
#endif #endif

View File

@ -383,7 +383,7 @@ extern int drm_ttm_destroy(struct drm_ttm *ttm);
* The array of page pointers was allocated with vmalloc * The array of page pointers was allocated with vmalloc
* instead of drm_calloc. * instead of drm_calloc.
*/ */
#define DRM_TTM_PAGE_VMALLOC (1 << 4) #define DRM_TTM_PAGEDIR_VMALLOC (1 << 4)
/* /*
* This ttm is mapped from user space * This ttm is mapped from user space
*/ */
@ -741,6 +741,10 @@ static inline void *drm_bmo_virtual(struct drm_bo_kmap_obj *map, int *is_iomem)
extern void drm_bo_kunmap(struct drm_bo_kmap_obj *map); extern void drm_bo_kunmap(struct drm_bo_kmap_obj *map);
extern int drm_bo_kmap(struct drm_buffer_object *bo, unsigned long start_page, extern int drm_bo_kmap(struct drm_buffer_object *bo, unsigned long start_page,
unsigned long num_pages, struct drm_bo_kmap_obj *map); unsigned long num_pages, struct drm_bo_kmap_obj *map);
extern int drm_bo_pfn_prot(struct drm_buffer_object *bo,
unsigned long dst_offset,
unsigned long *pfn,
pgprot_t *prot);
/* /*

View File

@ -42,11 +42,12 @@ void drm_ttm_cache_flush(void)
} }
EXPORT_SYMBOL(drm_ttm_cache_flush); EXPORT_SYMBOL(drm_ttm_cache_flush);
/* /**
* Use kmalloc if possible. Otherwise fall back to vmalloc. * Allocates storage for pointers to the pages that back the ttm.
*
* Uses kmalloc if possible. Otherwise falls back to vmalloc.
*/ */
static void drm_ttm_alloc_page_directory(struct drm_ttm *ttm)
static void drm_ttm_alloc_pages(struct drm_ttm *ttm)
{ {
unsigned long size = ttm->num_pages * sizeof(*ttm->pages); unsigned long size = ttm->num_pages * sizeof(*ttm->pages);
ttm->pages = NULL; ttm->pages = NULL;
@ -60,19 +61,19 @@ static void drm_ttm_alloc_pages(struct drm_ttm *ttm)
if (!ttm->pages) { if (!ttm->pages) {
ttm->pages = vmalloc_user(size); ttm->pages = vmalloc_user(size);
if (ttm->pages) if (ttm->pages)
ttm->page_flags |= DRM_TTM_PAGE_VMALLOC; ttm->page_flags |= DRM_TTM_PAGEDIR_VMALLOC;
} }
if (!ttm->pages) if (!ttm->pages)
drm_free_memctl(size); drm_free_memctl(size);
} }
static void drm_ttm_free_pages(struct drm_ttm *ttm) static void drm_ttm_free_page_directory(struct drm_ttm *ttm)
{ {
unsigned long size = ttm->num_pages * sizeof(*ttm->pages); unsigned long size = ttm->num_pages * sizeof(*ttm->pages);
if (ttm->page_flags & DRM_TTM_PAGE_VMALLOC) { if (ttm->page_flags & DRM_TTM_PAGEDIR_VMALLOC) {
vfree(ttm->pages); vfree(ttm->pages);
ttm->page_flags &= ~DRM_TTM_PAGE_VMALLOC; ttm->page_flags &= ~DRM_TTM_PAGEDIR_VMALLOC;
} else { } else {
drm_free(ttm->pages, size, DRM_MEM_TTM); drm_free(ttm->pages, size, DRM_MEM_TTM);
} }
@ -215,7 +216,7 @@ int drm_ttm_destroy(struct drm_ttm *ttm)
else else
drm_ttm_free_alloced_pages(ttm); drm_ttm_free_alloced_pages(ttm);
drm_ttm_free_pages(ttm); drm_ttm_free_page_directory(ttm);
} }
drm_ctl_free(ttm, sizeof(*ttm), DRM_MEM_TTM); drm_ctl_free(ttm, sizeof(*ttm), DRM_MEM_TTM);
@ -349,7 +350,7 @@ struct drm_ttm *drm_ttm_create(struct drm_device *dev, unsigned long size,
* Account also for AGP module memory usage. * Account also for AGP module memory usage.
*/ */
drm_ttm_alloc_pages(ttm); drm_ttm_alloc_page_directory(ttm);
if (!ttm->pages) { if (!ttm->pages) {
drm_ttm_destroy(ttm); drm_ttm_destroy(ttm);
DRM_ERROR("Failed allocating page table\n"); DRM_ERROR("Failed allocating page table\n");

View File

@ -645,8 +645,14 @@ struct drm_set_version {
#define DRM_FENCE_FLAG_EMIT 0x00000001 #define DRM_FENCE_FLAG_EMIT 0x00000001
#define DRM_FENCE_FLAG_SHAREABLE 0x00000002 #define DRM_FENCE_FLAG_SHAREABLE 0x00000002
/**
* On hardware with no interrupt events for operation completion,
* indicates that the kernel should sleep while waiting for any blocking
* operation to complete rather than spinning.
*
* Has no effect otherwise.
*/
#define DRM_FENCE_FLAG_WAIT_LAZY 0x00000004 #define DRM_FENCE_FLAG_WAIT_LAZY 0x00000004
#define DRM_FENCE_FLAG_WAIT_IGNORE_SIGNALS 0x00000008
#define DRM_FENCE_FLAG_NO_USER 0x00000010 #define DRM_FENCE_FLAG_NO_USER 0x00000010
/* Reserved for driver use */ /* Reserved for driver use */
@ -795,13 +801,12 @@ struct drm_fence_arg {
* with it as a result of this operation * with it as a result of this operation
*/ */
#define DRM_BO_HINT_DONT_FENCE 0x00000004 #define DRM_BO_HINT_DONT_FENCE 0x00000004
/* /**
* Sleep while waiting for the operation to complete. * On hardware with no interrupt events for operation completion,
* Without this flag, the kernel will, instead, spin * indicates that the kernel should sleep while waiting for any blocking
* until this operation has completed. I'm not sure * operation to complete rather than spinning.
* why you would ever want this, so please always *
* provide DRM_BO_HINT_WAIT_LAZY to any operation * Has no effect otherwise.
* which may block
*/ */
#define DRM_BO_HINT_WAIT_LAZY 0x00000008 #define DRM_BO_HINT_WAIT_LAZY 0x00000008
/* /*

View File

@ -804,6 +804,7 @@ struct i915_relocatee_info {
unsigned page_offset; unsigned page_offset;
struct drm_bo_kmap_obj kmap; struct drm_bo_kmap_obj kmap;
int is_iomem; int is_iomem;
int idle;
}; };
struct drm_i915_validate_buffer { struct drm_i915_validate_buffer {
@ -859,6 +860,14 @@ int i915_apply_reloc(struct drm_file *file_priv, int num_buffers,
drm_bo_kunmap(&relocatee->kmap); drm_bo_kunmap(&relocatee->kmap);
relocatee->data_page = NULL; relocatee->data_page = NULL;
relocatee->offset = new_cmd_offset; relocatee->offset = new_cmd_offset;
if (unlikely(!relocatee->idle)) {
ret = drm_bo_wait(relocatee->buf, 0, 0, 0);
if (ret)
return ret;
relocatee->idle = 1;
}
ret = drm_bo_kmap(relocatee->buf, new_cmd_offset >> PAGE_SHIFT, ret = drm_bo_kmap(relocatee->buf, new_cmd_offset >> PAGE_SHIFT,
1, &relocatee->kmap); 1, &relocatee->kmap);
if (ret) { if (ret) {
@ -1002,10 +1011,6 @@ static int i915_exec_reloc(struct drm_file *file_priv, drm_handle_t buf_handle,
} }
mutex_lock (&relocatee.buf->mutex); mutex_lock (&relocatee.buf->mutex);
ret = drm_bo_wait (relocatee.buf, 0, 0, FALSE);
if (ret)
goto out_err1;
while (reloc_user_ptr) { while (reloc_user_ptr) {
ret = i915_process_relocs(file_priv, buf_handle, &reloc_user_ptr, &relocatee, buffers, buf_count); ret = i915_process_relocs(file_priv, buf_handle, &reloc_user_ptr, &relocatee, buffers, buf_count);
if (ret) { if (ret) {

View File

@ -415,6 +415,13 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int plane)
if (i915_in_vblank(dev, pipe)) if (i915_in_vblank(dev, pipe))
count++; count++;
#endif #endif
/* count may be reset by other driver(e.g. 2D driver),
we have no way to know if it is wrapped or resetted
when count is zero. do a rough guess.
*/
if (count == 0 && dev->last_vblank[pipe] < dev->max_vblank_count/2)
dev->last_vblank[pipe] = 0;
return count; return count;
} }