aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_object.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-10-25 01:23:59 -0400
committerBen Skeggs <bskeggs@redhat.com>2010-12-03 00:11:47 -0500
commitdc1e5c0dbff27c2b5147eaea16c578d2337870c3 (patch)
tree82b7bd25bd162d5a9bcc5ee0598e697e1ddbd08e /drivers/gpu/drm/nouveau/nouveau_object.c
parentfce2bad0ee2666d6a10bfeb634b1021469cc3d79 (diff)
drm/nouveau: simplify gpuobj suspend/resume
Reviewed-by: Francisco Jerez <currojerez@riseup.net> 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.c56
1 files changed, 10 insertions, 46 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index 94429553433c..8c5e35cc04df 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -934,78 +934,42 @@ nouveau_gpuobj_suspend(struct drm_device *dev)
934 struct nouveau_gpuobj *gpuobj; 934 struct nouveau_gpuobj *gpuobj;
935 int i; 935 int i;
936 936
937 if (dev_priv->card_type < NV_50) {
938 dev_priv->susres.ramin_copy = vmalloc(dev_priv->ramin_rsvd_vram);
939 if (!dev_priv->susres.ramin_copy)
940 return -ENOMEM;
941
942 for (i = 0; i < dev_priv->ramin_rsvd_vram; i += 4)
943 dev_priv->susres.ramin_copy[i/4] = nv_ri32(dev, i);
944 return 0;
945 }
946
947 list_for_each_entry(gpuobj, &dev_priv->gpuobj_list, list) { 937 list_for_each_entry(gpuobj, &dev_priv->gpuobj_list, list) {
948 if (!gpuobj->im_backing) 938 if (gpuobj->cinst != 0xdeadbeef)
949 continue; 939 continue;
950 940
951 gpuobj->im_backing_suspend = vmalloc(gpuobj->size); 941 gpuobj->suspend = vmalloc(gpuobj->size);
952 if (!gpuobj->im_backing_suspend) { 942 if (!gpuobj->suspend) {
953 nouveau_gpuobj_resume(dev); 943 nouveau_gpuobj_resume(dev);
954 return -ENOMEM; 944 return -ENOMEM;
955 } 945 }
956 946
957 for (i = 0; i < gpuobj->size; i += 4) 947 for (i = 0; i < gpuobj->size; i += 4)
958 gpuobj->im_backing_suspend[i/4] = nv_ro32(gpuobj, i); 948 gpuobj->suspend[i/4] = nv_ro32(gpuobj, i);
959 } 949 }
960 950
961 return 0; 951 return 0;
962} 952}
963 953
964void 954void
965nouveau_gpuobj_suspend_cleanup(struct drm_device *dev)
966{
967 struct drm_nouveau_private *dev_priv = dev->dev_private;
968 struct nouveau_gpuobj *gpuobj;
969
970 if (dev_priv->card_type < NV_50) {
971 vfree(dev_priv->susres.ramin_copy);
972 dev_priv->susres.ramin_copy = NULL;
973 return;
974 }
975
976 list_for_each_entry(gpuobj, &dev_priv->gpuobj_list, list) {
977 if (!gpuobj->im_backing_suspend)
978 continue;
979
980 vfree(gpuobj->im_backing_suspend);
981 gpuobj->im_backing_suspend = NULL;
982 }
983}
984
985void
986nouveau_gpuobj_resume(struct drm_device *dev) 955nouveau_gpuobj_resume(struct drm_device *dev)
987{ 956{
988 struct drm_nouveau_private *dev_priv = dev->dev_private; 957 struct drm_nouveau_private *dev_priv = dev->dev_private;
989 struct nouveau_gpuobj *gpuobj; 958 struct nouveau_gpuobj *gpuobj;
990 int i; 959 int i;
991 960
992 if (dev_priv->card_type < NV_50) {
993 for (i = 0; i < dev_priv->ramin_rsvd_vram; i += 4)
994 nv_wi32(dev, i, dev_priv->susres.ramin_copy[i/4]);
995 nouveau_gpuobj_suspend_cleanup(dev);
996 return;
997 }
998
999 list_for_each_entry(gpuobj, &dev_priv->gpuobj_list, list) { 961 list_for_each_entry(gpuobj, &dev_priv->gpuobj_list, list) {
1000 if (!gpuobj->im_backing_suspend) 962 if (!gpuobj->suspend)
1001 continue; 963 continue;
1002 964
1003 for (i = 0; i < gpuobj->size; i += 4) 965 for (i = 0; i < gpuobj->size; i += 4)
1004 nv_wo32(gpuobj, i, gpuobj->im_backing_suspend[i/4]); 966 nv_wo32(gpuobj, i, gpuobj->suspend[i/4]);
1005 dev_priv->engine.instmem.flush(dev); 967
968 vfree(gpuobj->suspend);
969 gpuobj->suspend = NULL;
1006 } 970 }
1007 971
1008 nouveau_gpuobj_suspend_cleanup(dev); 972 dev_priv->engine.instmem.flush(dev);
1009} 973}
1010 974
1011int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data, 975int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data,