diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2011-05-30 21:11:28 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2011-06-23 01:58:15 -0400 |
commit | 3f0a68d8f8ba9d6c0cd9df948fbba90944c3da62 (patch) | |
tree | 8324d573e0ec5fc55e359e3d725bf8b9c7135bce /drivers | |
parent | 1562ffde94fc232e5b7d6d32f43abb3e25468dac (diff) |
drm/nouveau: allocate structure to store per-client data
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_state.c | 21 |
3 files changed, 32 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c index 7e25f5a6db96..76cd287c7cec 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.c +++ b/drivers/gpu/drm/nouveau/nouveau_drv.c | |||
@@ -393,7 +393,9 @@ static struct drm_driver driver = { | |||
393 | .firstopen = nouveau_firstopen, | 393 | .firstopen = nouveau_firstopen, |
394 | .lastclose = nouveau_lastclose, | 394 | .lastclose = nouveau_lastclose, |
395 | .unload = nouveau_unload, | 395 | .unload = nouveau_unload, |
396 | .open = nouveau_open, | ||
396 | .preclose = nouveau_preclose, | 397 | .preclose = nouveau_preclose, |
398 | .postclose = nouveau_postclose, | ||
397 | #if defined(CONFIG_DRM_NOUVEAU_DEBUG) | 399 | #if defined(CONFIG_DRM_NOUVEAU_DEBUG) |
398 | .debugfs_init = nouveau_debugfs_init, | 400 | .debugfs_init = nouveau_debugfs_init, |
399 | .debugfs_cleanup = nouveau_debugfs_takedown, | 401 | .debugfs_cleanup = nouveau_debugfs_takedown, |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 86eb3f40c4f8..a378a9648198 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -46,9 +46,15 @@ | |||
46 | #include "ttm/ttm_module.h" | 46 | #include "ttm/ttm_module.h" |
47 | 47 | ||
48 | struct nouveau_fpriv { | 48 | struct nouveau_fpriv { |
49 | struct ttm_object_file *tfile; | 49 | spinlock_t lock; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static inline struct nouveau_fpriv * | ||
53 | nouveau_fpriv(struct drm_file *file_priv) | ||
54 | { | ||
55 | return file_priv ? file_priv->driver_priv : NULL; | ||
56 | } | ||
57 | |||
52 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) | 58 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
53 | 59 | ||
54 | #include "nouveau_drm.h" | 60 | #include "nouveau_drm.h" |
@@ -792,7 +798,9 @@ extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state); | |||
792 | extern int nouveau_pci_resume(struct pci_dev *pdev); | 798 | extern int nouveau_pci_resume(struct pci_dev *pdev); |
793 | 799 | ||
794 | /* nouveau_state.c */ | 800 | /* nouveau_state.c */ |
801 | extern int nouveau_open(struct drm_device *, struct drm_file *); | ||
795 | extern void nouveau_preclose(struct drm_device *dev, struct drm_file *); | 802 | extern void nouveau_preclose(struct drm_device *dev, struct drm_file *); |
803 | extern void nouveau_postclose(struct drm_device *, struct drm_file *); | ||
796 | extern int nouveau_load(struct drm_device *, unsigned long flags); | 804 | extern int nouveau_load(struct drm_device *, unsigned long flags); |
797 | extern int nouveau_firstopen(struct drm_device *); | 805 | extern int nouveau_firstopen(struct drm_device *); |
798 | extern void nouveau_lastclose(struct drm_device *); | 806 | extern void nouveau_lastclose(struct drm_device *); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index a0e17340e145..9aa96b9375ae 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -764,6 +764,20 @@ static void nouveau_card_takedown(struct drm_device *dev) | |||
764 | vga_client_register(dev->pdev, NULL, NULL, NULL); | 764 | vga_client_register(dev->pdev, NULL, NULL, NULL); |
765 | } | 765 | } |
766 | 766 | ||
767 | int | ||
768 | nouveau_open(struct drm_device *dev, struct drm_file *file_priv) | ||
769 | { | ||
770 | struct nouveau_fpriv *fpriv; | ||
771 | |||
772 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); | ||
773 | if (unlikely(!fpriv)) | ||
774 | return -ENOMEM; | ||
775 | |||
776 | spin_lock_init(&fpriv->lock); | ||
777 | file_priv->driver_priv = fpriv; | ||
778 | return 0; | ||
779 | } | ||
780 | |||
767 | /* here a client dies, release the stuff that was allocated for its | 781 | /* here a client dies, release the stuff that was allocated for its |
768 | * file_priv */ | 782 | * file_priv */ |
769 | void nouveau_preclose(struct drm_device *dev, struct drm_file *file_priv) | 783 | void nouveau_preclose(struct drm_device *dev, struct drm_file *file_priv) |
@@ -771,6 +785,13 @@ void nouveau_preclose(struct drm_device *dev, struct drm_file *file_priv) | |||
771 | nouveau_channel_cleanup(dev, file_priv); | 785 | nouveau_channel_cleanup(dev, file_priv); |
772 | } | 786 | } |
773 | 787 | ||
788 | void | ||
789 | nouveau_postclose(struct drm_device *dev, struct drm_file *file_priv) | ||
790 | { | ||
791 | struct nouveau_fpriv *fpriv = nouveau_fpriv(file_priv); | ||
792 | kfree(fpriv); | ||
793 | } | ||
794 | |||
774 | /* first module load, setup the mmio/fb mapping */ | 795 | /* first module load, setup the mmio/fb mapping */ |
775 | /* KMS: we need mmio at load time, not when the first drm client opens. */ | 796 | /* KMS: we need mmio at load time, not when the first drm client opens. */ |
776 | int nouveau_firstopen(struct drm_device *dev) | 797 | int nouveau_firstopen(struct drm_device *dev) |