diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2010-10-19 05:57:34 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2010-12-03 00:06:54 -0500 |
commit | a6a1a38075661bec189f2bad7912f8861e6ce357 (patch) | |
tree | 0c58a39eb33012c32f0ebb86079bf5c3d6b6fa90 /drivers/gpu/drm/nouveau/nouveau_object.c | |
parent | 50536946faaf3d9ac0245838eb09e5eb1065b06c (diff) |
drm/nouveau: use object class structs more extensively
The structs themselves, as well as the non-sw object creation function are
probably very misnamed now. That's a problem for later :)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_object.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_object.c | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c index 70ffd753050..9c26da4cdc0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_object.c +++ b/drivers/gpu/drm/nouveau/nouveau_object.c | |||
@@ -495,23 +495,67 @@ nouveau_gpuobj_gart_dma_new(struct nouveau_channel *chan, | |||
495 | entry[5]: | 495 | entry[5]: |
496 | set to 0? | 496 | set to 0? |
497 | */ | 497 | */ |
498 | static int | ||
499 | nouveau_gpuobj_sw_new(struct nouveau_channel *chan, int class, | ||
500 | struct nouveau_gpuobj **gpuobj_ret) | ||
501 | { | ||
502 | struct drm_nouveau_private *dev_priv; | ||
503 | struct nouveau_gpuobj *gpuobj; | ||
504 | |||
505 | if (!chan || !gpuobj_ret || *gpuobj_ret != NULL) | ||
506 | return -EINVAL; | ||
507 | dev_priv = chan->dev->dev_private; | ||
508 | |||
509 | gpuobj = kzalloc(sizeof(*gpuobj), GFP_KERNEL); | ||
510 | if (!gpuobj) | ||
511 | return -ENOMEM; | ||
512 | gpuobj->dev = chan->dev; | ||
513 | gpuobj->engine = NVOBJ_ENGINE_SW; | ||
514 | gpuobj->class = class; | ||
515 | kref_init(&gpuobj->refcount); | ||
516 | gpuobj->cinst = 0x40; | ||
517 | |||
518 | spin_lock(&dev_priv->ramin_lock); | ||
519 | list_add_tail(&gpuobj->list, &dev_priv->gpuobj_list); | ||
520 | spin_unlock(&dev_priv->ramin_lock); | ||
521 | *gpuobj_ret = gpuobj; | ||
522 | return 0; | ||
523 | } | ||
524 | |||
498 | int | 525 | int |
499 | nouveau_gpuobj_gr_new(struct nouveau_channel *chan, int class, | 526 | nouveau_gpuobj_gr_new(struct nouveau_channel *chan, int class, |
500 | struct nouveau_gpuobj **gpuobj) | 527 | struct nouveau_gpuobj **gpuobj) |
501 | { | 528 | { |
529 | struct drm_nouveau_private *dev_priv = chan->dev->dev_private; | ||
530 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
531 | struct nouveau_pgraph_object_class *grc; | ||
502 | struct drm_device *dev = chan->dev; | 532 | struct drm_device *dev = chan->dev; |
503 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
504 | int ret; | 533 | int ret; |
505 | 534 | ||
506 | NV_DEBUG(dev, "ch%d class=0x%04x\n", chan->id, class); | 535 | NV_DEBUG(dev, "ch%d class=0x%04x\n", chan->id, class); |
507 | 536 | ||
537 | grc = pgraph->grclass; | ||
538 | while (grc->id) { | ||
539 | if (grc->id == class) | ||
540 | break; | ||
541 | grc++; | ||
542 | } | ||
543 | |||
544 | if (!grc->id) { | ||
545 | NV_ERROR(dev, "illegal object class: 0x%x\n", class); | ||
546 | return -EINVAL; | ||
547 | } | ||
548 | |||
549 | if (grc->engine == NVOBJ_ENGINE_SW) | ||
550 | return nouveau_gpuobj_sw_new(chan, class, gpuobj); | ||
551 | |||
508 | ret = nouveau_gpuobj_new(dev, chan, | 552 | ret = nouveau_gpuobj_new(dev, chan, |
509 | nouveau_gpuobj_class_instmem_size(dev, class), | 553 | nouveau_gpuobj_class_instmem_size(dev, class), |
510 | 16, | 554 | 16, |
511 | NVOBJ_FLAG_ZERO_ALLOC | NVOBJ_FLAG_ZERO_FREE, | 555 | NVOBJ_FLAG_ZERO_ALLOC | NVOBJ_FLAG_ZERO_FREE, |
512 | gpuobj); | 556 | gpuobj); |
513 | if (ret) { | 557 | if (ret) { |
514 | NV_ERROR(dev, "Error creating gpuobj: %d\n", ret); | 558 | NV_ERROR(dev, "error creating gpuobj: %d\n", ret); |
515 | return ret; | 559 | return ret; |
516 | } | 560 | } |
517 | 561 | ||
@@ -541,38 +585,11 @@ nouveau_gpuobj_gr_new(struct nouveau_channel *chan, int class, | |||
541 | } | 585 | } |
542 | dev_priv->engine.instmem.flush(dev); | 586 | dev_priv->engine.instmem.flush(dev); |
543 | 587 | ||
544 | (*gpuobj)->engine = NVOBJ_ENGINE_GR; | 588 | (*gpuobj)->engine = grc->engine; |
545 | (*gpuobj)->class = class; | 589 | (*gpuobj)->class = class; |
546 | return 0; | 590 | return 0; |
547 | } | 591 | } |
548 | 592 | ||
549 | int | ||
550 | nouveau_gpuobj_sw_new(struct nouveau_channel *chan, int class, | ||
551 | struct nouveau_gpuobj **gpuobj_ret) | ||
552 | { | ||
553 | struct drm_nouveau_private *dev_priv; | ||
554 | struct nouveau_gpuobj *gpuobj; | ||
555 | |||
556 | if (!chan || !gpuobj_ret || *gpuobj_ret != NULL) | ||
557 | return -EINVAL; | ||
558 | dev_priv = chan->dev->dev_private; | ||
559 | |||
560 | gpuobj = kzalloc(sizeof(*gpuobj), GFP_KERNEL); | ||
561 | if (!gpuobj) | ||
562 | return -ENOMEM; | ||
563 | gpuobj->dev = chan->dev; | ||
564 | gpuobj->engine = NVOBJ_ENGINE_SW; | ||
565 | gpuobj->class = class; | ||
566 | kref_init(&gpuobj->refcount); | ||
567 | gpuobj->cinst = 0x40; | ||
568 | |||
569 | spin_lock(&dev_priv->ramin_lock); | ||
570 | list_add_tail(&gpuobj->list, &dev_priv->gpuobj_list); | ||
571 | spin_unlock(&dev_priv->ramin_lock); | ||
572 | *gpuobj_ret = gpuobj; | ||
573 | return 0; | ||
574 | } | ||
575 | |||
576 | static int | 593 | static int |
577 | nouveau_gpuobj_channel_init_pramin(struct nouveau_channel *chan) | 594 | nouveau_gpuobj_channel_init_pramin(struct nouveau_channel *chan) |
578 | { | 595 | { |
@@ -868,10 +885,7 @@ nouveau_gpuobj_resume(struct drm_device *dev) | |||
868 | int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data, | 885 | int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data, |
869 | struct drm_file *file_priv) | 886 | struct drm_file *file_priv) |
870 | { | 887 | { |
871 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
872 | struct drm_nouveau_grobj_alloc *init = data; | 888 | struct drm_nouveau_grobj_alloc *init = data; |
873 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
874 | struct nouveau_pgraph_object_class *grc; | ||
875 | struct nouveau_gpuobj *gr = NULL; | 889 | struct nouveau_gpuobj *gr = NULL; |
876 | struct nouveau_channel *chan; | 890 | struct nouveau_channel *chan; |
877 | int ret; | 891 | int ret; |
@@ -879,18 +893,6 @@ int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data, | |||
879 | if (init->handle == ~0) | 893 | if (init->handle == ~0) |
880 | return -EINVAL; | 894 | return -EINVAL; |
881 | 895 | ||
882 | grc = pgraph->grclass; | ||
883 | while (grc->id) { | ||
884 | if (grc->id == init->class) | ||
885 | break; | ||
886 | grc++; | ||
887 | } | ||
888 | |||
889 | if (!grc->id) { | ||
890 | NV_ERROR(dev, "Illegal object class: 0x%x\n", init->class); | ||
891 | return -EPERM; | ||
892 | } | ||
893 | |||
894 | chan = nouveau_channel_get(dev, file_priv, init->channel); | 896 | chan = nouveau_channel_get(dev, file_priv, init->channel); |
895 | if (IS_ERR(chan)) | 897 | if (IS_ERR(chan)) |
896 | return PTR_ERR(chan); | 898 | return PTR_ERR(chan); |
@@ -900,10 +902,7 @@ int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data, | |||
900 | goto out; | 902 | goto out; |
901 | } | 903 | } |
902 | 904 | ||
903 | if (grc->engine != NVOBJ_ENGINE_SW) | 905 | ret = nouveau_gpuobj_gr_new(chan, init->class, &gr); |
904 | ret = nouveau_gpuobj_gr_new(chan, grc->id, &gr); | ||
905 | else | ||
906 | ret = nouveau_gpuobj_sw_new(chan, grc->id, &gr); | ||
907 | if (ret) { | 906 | if (ret) { |
908 | NV_ERROR(dev, "Error creating object: %d (%d/0x%08x)\n", | 907 | NV_ERROR(dev, "Error creating object: %d (%d/0x%08x)\n", |
909 | ret, init->channel, init->handle); | 908 | ret, init->channel, init->handle); |