Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199677
b: refs/heads/master
c: afeb3e1
h: refs/heads/master
i:
  199675: e478b82
v: v3
  • Loading branch information
Dave Airlie committed Jun 1, 2010
1 parent 167141d commit 8d19597
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 472 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c09a35028567ae2c11d627bf69134b87a3c0efae
refs/heads/master: afeb3e11147adb357603b071d6d7d1f30ea7f19d
59 changes: 58 additions & 1 deletion trunk/drivers/gpu/drm/nouveau/nouveau_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static struct nouveau_dsm_priv {
bool dsm_detected;
acpi_handle dhandle;
acpi_handle dsm_handle;
acpi_handle rom_handle;
} nouveau_dsm_priv;

static const char nouveau_dsm_muid[] = {
Expand Down Expand Up @@ -151,12 +152,13 @@ static bool nouveau_dsm_pci_probe(struct pci_dev *pdev)
dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
if (!dhandle)
return false;

status = acpi_get_handle(dhandle, "_DSM", &nvidia_handle);
if (ACPI_FAILURE(status)) {
return false;
}

ret= nouveau_dsm(nvidia_handle, NOUVEAU_DSM_SUPPORTED,
ret = nouveau_dsm(nvidia_handle, NOUVEAU_DSM_SUPPORTED,
NOUVEAU_DSM_SUPPORTED_FUNCTIONS, &result);
if (ret < 0)
return false;
Expand All @@ -173,6 +175,7 @@ static bool nouveau_dsm_detect(void)
struct pci_dev *pdev = NULL;
int has_dsm = 0;
int vga_count = 0;

while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
vga_count++;

Expand Down Expand Up @@ -204,3 +207,57 @@ void nouveau_unregister_dsm_handler(void)
{
vga_switcheroo_unregister_handler();
}

/* retrieve the ROM in 4k blocks */
static int nouveau_rom_call(acpi_handle rom_handle, uint8_t *bios,
int offset, int len)
{
acpi_status status;
union acpi_object rom_arg_elements[2], *obj;
struct acpi_object_list rom_arg;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};

rom_arg.count = 2;
rom_arg.pointer = &rom_arg_elements[0];

rom_arg_elements[0].type = ACPI_TYPE_INTEGER;
rom_arg_elements[0].integer.value = offset;

rom_arg_elements[1].type = ACPI_TYPE_INTEGER;
rom_arg_elements[1].integer.value = len;

status = acpi_evaluate_object(rom_handle, NULL, &rom_arg, &buffer);
if (ACPI_FAILURE(status)) {
printk(KERN_INFO "failed to evaluate ROM got %s\n", acpi_format_exception(status));
return -ENODEV;
}
obj = (union acpi_object *)buffer.pointer;
memcpy(bios+offset, obj->buffer.pointer, len);
kfree(buffer.pointer);
return len;
}

bool nouveau_acpi_rom_supported(struct pci_dev *pdev)
{
acpi_status status;
acpi_handle dhandle, rom_handle;

if (!nouveau_dsm_priv.dsm_detected)
return false;

dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
if (!dhandle)
return false;

status = acpi_get_handle(dhandle, "_ROM", &rom_handle);
if (ACPI_FAILURE(status))
return false;

nouveau_dsm_priv.rom_handle = rom_handle;
return true;
}

int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len)
{
return nouveau_rom_call(nouveau_dsm_priv.rom_handle, bios, offset, len);
}
20 changes: 20 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@ static void load_vbios_pci(struct drm_device *dev, uint8_t *data)
pci_disable_rom(dev->pdev);
}

static void load_vbios_acpi(struct drm_device *dev, uint8_t *data)
{
int i;
int ret;
int size = 64 * 1024;

if (!nouveau_acpi_rom_supported(dev->pdev))
return;

for (i = 0; i < (size / ROM_BIOS_PAGE); i++) {
ret = nouveau_acpi_get_bios_chunk(data,
(i * ROM_BIOS_PAGE),
ROM_BIOS_PAGE);
if (ret <= 0)
break;
}
return;
}

struct methods {
const char desc[8];
void (*loadbios)(struct drm_device *, uint8_t *);
Expand All @@ -191,6 +210,7 @@ static struct methods nv04_methods[] = {
};

static struct methods nv50_methods[] = {
{ "ACPI", load_vbios_acpi, true },
{ "PRAMIN", load_vbios_pramin, true },
{ "PROM", load_vbios_prom, false },
{ "PCIROM", load_vbios_pci, true },
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,17 @@ extern int nouveau_dma_init(struct nouveau_channel *);
extern int nouveau_dma_wait(struct nouveau_channel *, int slots, int size);

/* nouveau_acpi.c */
#define ROM_BIOS_PAGE 4096
#if defined(CONFIG_ACPI)
void nouveau_register_dsm_handler(void);
void nouveau_unregister_dsm_handler(void);
int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len);
bool nouveau_acpi_rom_supported(struct pci_dev *pdev);
#else
static inline void nouveau_register_dsm_handler(void) {}
static inline void nouveau_unregister_dsm_handler(void) {}
static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; }
static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; }
#endif

/* nouveau_backlight.c */
Expand Down
64 changes: 27 additions & 37 deletions trunk/drivers/gpu/drm/ttm/ttm_page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct ttm_page_pool {
/**
* Limits for the pool. They are handled without locks because only place where
* they may change is in sysfs store. They won't have immediate effect anyway
* so forcing serialization to access them is pointless.
* so forcing serialiazation to access them is pointless.
*/

struct ttm_pool_opts {
Expand Down Expand Up @@ -165,18 +165,16 @@ static ssize_t ttm_pool_store(struct kobject *kobj,
m->options.small = val;
else if (attr == &ttm_page_pool_alloc_size) {
if (val > NUM_PAGES_TO_ALLOC*8) {
printk(KERN_ERR TTM_PFX
"Setting allocation size to %lu "
"is not allowed. Recommended size is "
"%lu\n",
NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7),
NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
printk(KERN_ERR "[ttm] Setting allocation size to %lu "
"is not allowed. Recomended size is "
"%lu\n",
NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7),
NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
return size;
} else if (val > NUM_PAGES_TO_ALLOC) {
printk(KERN_WARNING TTM_PFX
"Setting allocation size to "
"larger than %lu is not recommended.\n",
NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
printk(KERN_WARNING "[ttm] Setting allocation size to "
"larger than %lu is not recomended.\n",
NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
}
m->options.alloc_size = val;
}
Expand Down Expand Up @@ -279,7 +277,7 @@ static void ttm_pages_put(struct page *pages[], unsigned npages)
{
unsigned i;
if (set_pages_array_wb(pages, npages))
printk(KERN_ERR TTM_PFX "Failed to set %d pages to wb!\n",
printk(KERN_ERR "[ttm] Failed to set %d pages to wb!\n",
npages);
for (i = 0; i < npages; ++i)
__free_page(pages[i]);
Expand Down Expand Up @@ -315,8 +313,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free)
pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
GFP_KERNEL);
if (!pages_to_free) {
printk(KERN_ERR TTM_PFX
"Failed to allocate memory for pool free operation.\n");
printk(KERN_ERR "Failed to allocate memory for pool free operation.\n");
return 0;
}

Expand Down Expand Up @@ -393,7 +390,7 @@ static int ttm_pool_get_num_unused_pages(void)
}

/**
* Callback for mm to request pool to reduce number of page held.
* Calback for mm to request pool to reduce number of page held.
*/
static int ttm_pool_mm_shrink(int shrink_pages, gfp_t gfp_mask)
{
Expand Down Expand Up @@ -436,16 +433,14 @@ static int ttm_set_pages_caching(struct page **pages,
case tt_uncached:
r = set_pages_array_uc(pages, cpages);
if (r)
printk(KERN_ERR TTM_PFX
"Failed to set %d pages to uc!\n",
cpages);
printk(KERN_ERR "[ttm] Failed to set %d pages to uc!\n",
cpages);
break;
case tt_wc:
r = set_pages_array_wc(pages, cpages);
if (r)
printk(KERN_ERR TTM_PFX
"Failed to set %d pages to wc!\n",
cpages);
printk(KERN_ERR "[ttm] Failed to set %d pages to wc!\n",
cpages);
break;
default:
break;
Expand All @@ -463,7 +458,7 @@ static void ttm_handle_caching_state_failure(struct list_head *pages,
struct page **failed_pages, unsigned cpages)
{
unsigned i;
/* Failed pages have to be freed */
/* Failed pages has to be reed */
for (i = 0; i < cpages; ++i) {
list_del(&failed_pages[i]->lru);
__free_page(failed_pages[i]);
Expand All @@ -490,22 +485,20 @@ static int ttm_alloc_new_pages(struct list_head *pages, int gfp_flags,
caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);

if (!caching_array) {
printk(KERN_ERR TTM_PFX
"Unable to allocate table for new pages.");
printk(KERN_ERR "[ttm] unable to allocate table for new pages.");
return -ENOMEM;
}

for (i = 0, cpages = 0; i < count; ++i) {
p = alloc_page(gfp_flags);

if (!p) {
printk(KERN_ERR TTM_PFX "Unable to get page %u.\n", i);
printk(KERN_ERR "[ttm] unable to get page %u\n", i);

/* store already allocated pages in the pool after
* setting the caching state */
if (cpages) {
r = ttm_set_pages_caching(caching_array,
cstate, cpages);
r = ttm_set_pages_caching(caching_array, cstate, cpages);
if (r)
ttm_handle_caching_state_failure(pages,
ttm_flags, cstate,
Expand Down Expand Up @@ -597,8 +590,7 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
++pool->nrefills;
pool->npages += alloc_size;
} else {
printk(KERN_ERR TTM_PFX
"Failed to fill pool (%p).", pool);
printk(KERN_ERR "[ttm] Failed to fill pool (%p).", pool);
/* If we have any pages left put them to the pool. */
list_for_each_entry(p, &pool->list, lru) {
++cpages;
Expand Down Expand Up @@ -679,14 +671,13 @@ int ttm_get_pages(struct list_head *pages, int flags,
if (flags & TTM_PAGE_FLAG_DMA32)
gfp_flags |= GFP_DMA32;
else
gfp_flags |= GFP_HIGHUSER;
gfp_flags |= __GFP_HIGHMEM;

for (r = 0; r < count; ++r) {
p = alloc_page(gfp_flags);
if (!p) {

printk(KERN_ERR TTM_PFX
"Unable to allocate page.");
printk(KERN_ERR "[ttm] unable to allocate page.");
return -ENOMEM;
}

Expand Down Expand Up @@ -718,9 +709,8 @@ int ttm_get_pages(struct list_head *pages, int flags,
if (r) {
/* If there is any pages in the list put them back to
* the pool. */
printk(KERN_ERR TTM_PFX
"Failed to allocate extra pages "
"for large request.");
printk(KERN_ERR "[ttm] Failed to allocate extra pages "
"for large request.");
ttm_put_pages(pages, 0, flags, cstate);
return r;
}
Expand Down Expand Up @@ -788,7 +778,7 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
if (atomic_add_return(1, &_manager.page_alloc_inited) > 1)
return 0;

printk(KERN_INFO TTM_PFX "Initializing pool allocator.\n");
printk(KERN_INFO "[ttm] Initializing pool allocator.\n");

ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER, "wc");

Expand Down Expand Up @@ -823,7 +813,7 @@ void ttm_page_alloc_fini()
if (atomic_sub_return(1, &_manager.page_alloc_inited) > 0)
return;

printk(KERN_INFO TTM_PFX "Finalizing pool allocator.\n");
printk(KERN_INFO "[ttm] Finilizing pool allocator.\n");
ttm_pool_mm_shrink_fini(&_manager);

for (i = 0; i < NUM_POOLS; ++i)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/gpu/drm/vmwgfx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ccflags-y := -Iinclude/drm
vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \
vmwgfx_fb.o vmwgfx_ioctl.o vmwgfx_resource.o vmwgfx_buffer.o \
vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \
vmwgfx_overlay.o vmwgfx_fence.o
vmwgfx_overlay.o

obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
17 changes: 8 additions & 9 deletions trunk/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
goto out_err3;
}

/* Need mmio memory to check for fifo pitchlock cap. */
if (!(dev_priv->capabilities & SVGA_CAP_DISPLAY_TOPOLOGY) &&
!(dev_priv->capabilities & SVGA_CAP_PITCHLOCK) &&
!vmw_fifo_have_pitchlock(dev_priv)) {
ret = -ENOSYS;
DRM_ERROR("Hardware has no pitchlock\n");
goto out_err4;
}

dev_priv->tdev = ttm_object_device_init
(dev_priv->mem_global_ref.object, 12);

Expand Down Expand Up @@ -408,6 +399,8 @@ static int vmw_driver_unload(struct drm_device *dev)
{
struct vmw_private *dev_priv = vmw_priv(dev);

DRM_INFO(VMWGFX_DRIVER_NAME " unload.\n");

unregister_pm_notifier(&dev_priv->pm_nb);

vmw_fb_close(dev_priv);
Expand Down Expand Up @@ -553,6 +546,7 @@ static int vmw_master_create(struct drm_device *dev,
{
struct vmw_master *vmaster;

DRM_INFO("Master create.\n");
vmaster = kzalloc(sizeof(*vmaster), GFP_KERNEL);
if (unlikely(vmaster == NULL))
return -ENOMEM;
Expand All @@ -569,6 +563,7 @@ static void vmw_master_destroy(struct drm_device *dev,
{
struct vmw_master *vmaster = vmw_master(master);

DRM_INFO("Master destroy.\n");
master->driver_priv = NULL;
kfree(vmaster);
}
Expand All @@ -584,6 +579,8 @@ static int vmw_master_set(struct drm_device *dev,
struct vmw_master *vmaster = vmw_master(file_priv->master);
int ret = 0;

DRM_INFO("Master set.\n");

if (active) {
BUG_ON(active != &dev_priv->fbdev_master);
ret = ttm_vt_lock(&active->lock, false, vmw_fp->tfile);
Expand Down Expand Up @@ -625,6 +622,8 @@ static void vmw_master_drop(struct drm_device *dev,
struct vmw_master *vmaster = vmw_master(file_priv->master);
int ret;

DRM_INFO("Master drop.\n");

/**
* Make sure the master doesn't disappear while we have
* it locked.
Expand Down
Loading

0 comments on commit 8d19597

Please sign in to comment.