Deleted Added
full compact
drm_dma.c (182080) drm_dma.c (183573)
1/*-
2 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation

--- 15 unchanged lines hidden (view full) ---

24 *
25 * Authors:
26 * Rickard E. (Rik) Faith <faith@valinux.com>
27 * Gareth Hughes <gareth@valinux.com>
28 *
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation

--- 15 unchanged lines hidden (view full) ---

24 *
25 * Authors:
26 * Rickard E. (Rik) Faith <faith@valinux.com>
27 * Gareth Hughes <gareth@valinux.com>
28 *
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/drm/drm_dma.c 182080 2008-08-23 20:59:12Z rnoland $");
32__FBSDID("$FreeBSD: head/sys/dev/drm/drm_dma.c 183573 2008-10-03 16:59:11Z rnoland $");
33
34/** @file drm_dma.c
35 * Support code for DMA buffer management.
36 *
37 * The implementation used to be significantly more complicated, but the
38 * complexity has been moved into the drivers as different buffer management
39 * schemes evolved.
40 */

--- 15 unchanged lines hidden (view full) ---

56void drm_dma_takedown(struct drm_device *dev)
57{
58 drm_device_dma_t *dma = dev->dma;
59 int i, j;
60
61 if (dma == NULL)
62 return;
63
33
34/** @file drm_dma.c
35 * Support code for DMA buffer management.
36 *
37 * The implementation used to be significantly more complicated, but the
38 * complexity has been moved into the drivers as different buffer management
39 * schemes evolved.
40 */

--- 15 unchanged lines hidden (view full) ---

56void drm_dma_takedown(struct drm_device *dev)
57{
58 drm_device_dma_t *dma = dev->dma;
59 int i, j;
60
61 if (dma == NULL)
62 return;
63
64 /* Clear dma buffers */
64 /* Clear dma buffers */
65 for (i = 0; i <= DRM_MAX_ORDER; i++) {
66 if (dma->bufs[i].seg_count) {
67 DRM_DEBUG("order %d: buf_count = %d,"
65 for (i = 0; i <= DRM_MAX_ORDER; i++) {
66 if (dma->bufs[i].seg_count) {
67 DRM_DEBUG("order %d: buf_count = %d,"
68 " seg_count = %d\n",
69 i,
70 dma->bufs[i].buf_count,
71 dma->bufs[i].seg_count);
68 " seg_count = %d\n", i, dma->bufs[i].buf_count,
69 dma->bufs[i].seg_count);
72 for (j = 0; j < dma->bufs[i].seg_count; j++) {
73 drm_pci_free(dev, dma->bufs[i].seglist[j]);
74 }
75 free(dma->bufs[i].seglist, M_DRM);
76 }
77
78 if (dma->bufs[i].buf_count) {
79 for (j = 0; j < dma->bufs[i].buf_count; j++) {

--- 9 unchanged lines hidden (view full) ---

89 free(dev->dma, M_DRM);
90 dev->dma = NULL;
91 DRM_SPINUNINIT(&dev->dma_lock);
92}
93
94
95void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf)
96{
70 for (j = 0; j < dma->bufs[i].seg_count; j++) {
71 drm_pci_free(dev, dma->bufs[i].seglist[j]);
72 }
73 free(dma->bufs[i].seglist, M_DRM);
74 }
75
76 if (dma->bufs[i].buf_count) {
77 for (j = 0; j < dma->bufs[i].buf_count; j++) {

--- 9 unchanged lines hidden (view full) ---

87 free(dev->dma, M_DRM);
88 dev->dma = NULL;
89 DRM_SPINUNINIT(&dev->dma_lock);
90}
91
92
93void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf)
94{
97 if (!buf) return;
95 if (!buf)
96 return;
98
99 buf->pending = 0;
100 buf->file_priv= NULL;
101 buf->used = 0;
102}
103
104void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
105{
106 drm_device_dma_t *dma = dev->dma;
107 int i;
108
97
98 buf->pending = 0;
99 buf->file_priv= NULL;
100 buf->used = 0;
101}
102
103void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
104{
105 drm_device_dma_t *dma = dev->dma;
106 int i;
107
109 if (!dma) return;
108 if (!dma)
109 return;
110
110 for (i = 0; i < dma->buf_count; i++) {
111 if (dma->buflist[i]->file_priv == file_priv) {
112 switch (dma->buflist[i]->list) {
113 case DRM_LIST_NONE:
114 drm_free_buffer(dev, dma->buflist[i]);
115 break;
116 case DRM_LIST_WAIT:
117 dma->buflist[i]->list = DRM_LIST_RECLAIM;

--- 5 unchanged lines hidden (view full) ---

123 }
124 }
125}
126
127/* Call into the driver-specific DMA handler */
128int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv)
129{
130
111 for (i = 0; i < dma->buf_count; i++) {
112 if (dma->buflist[i]->file_priv == file_priv) {
113 switch (dma->buflist[i]->list) {
114 case DRM_LIST_NONE:
115 drm_free_buffer(dev, dma->buflist[i]);
116 break;
117 case DRM_LIST_WAIT:
118 dma->buflist[i]->list = DRM_LIST_RECLAIM;

--- 5 unchanged lines hidden (view full) ---

124 }
125 }
126}
127
128/* Call into the driver-specific DMA handler */
129int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv)
130{
131
131 if (dev->driver.dma_ioctl) {
132 if (dev->driver->dma_ioctl) {
132 /* shared code returns -errno */
133 /* shared code returns -errno */
133 return -dev->driver.dma_ioctl(dev, data, file_priv);
134 return -dev->driver->dma_ioctl(dev, data, file_priv);
134 } else {
135 DRM_DEBUG("DMA ioctl on driver with no dma handler\n");
136 return EINVAL;
137 }
138}
135 } else {
136 DRM_DEBUG("DMA ioctl on driver with no dma handler\n");
137 return EINVAL;
138 }
139}