Skip to content

Commit 687fbb2

Browse files
danvetairlied
authored andcommitted
drm: rip out DRIVER_FB_DMA and related code
No driver ever sets that flag, so good riddance! Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent b0e898a commit 687fbb2

2 files changed

Lines changed: 2 additions & 160 deletions

File tree

‎drivers/gpu/drm/drm_bufs.c‎

Lines changed: 2 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,161 +1130,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
11301130
return 0;
11311131
}
11321132

1133-
static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request)
1134-
{
1135-
struct drm_device_dma *dma = dev->dma;
1136-
struct drm_buf_entry *entry;
1137-
struct drm_buf *buf;
1138-
unsigned long offset;
1139-
unsigned long agp_offset;
1140-
int count;
1141-
int order;
1142-
int size;
1143-
int alignment;
1144-
int page_order;
1145-
int total;
1146-
int byte_count;
1147-
int i;
1148-
struct drm_buf **temp_buflist;
1149-
1150-
if (!drm_core_check_feature(dev, DRIVER_FB_DMA))
1151-
return -EINVAL;
1152-
1153-
if (!dma)
1154-
return -EINVAL;
1155-
1156-
if (!capable(CAP_SYS_ADMIN))
1157-
return -EPERM;
1158-
1159-
count = request->count;
1160-
order = order_base_2(request->size);
1161-
size = 1 << order;
1162-
1163-
alignment = (request->flags & _DRM_PAGE_ALIGN)
1164-
? PAGE_ALIGN(size) : size;
1165-
page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
1166-
total = PAGE_SIZE << page_order;
1167-
1168-
byte_count = 0;
1169-
agp_offset = request->agp_start;
1170-
1171-
DRM_DEBUG("count: %d\n", count);
1172-
DRM_DEBUG("order: %d\n", order);
1173-
DRM_DEBUG("size: %d\n", size);
1174-
DRM_DEBUG("agp_offset: %lu\n", agp_offset);
1175-
DRM_DEBUG("alignment: %d\n", alignment);
1176-
DRM_DEBUG("page_order: %d\n", page_order);
1177-
DRM_DEBUG("total: %d\n", total);
1178-
1179-
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
1180-
return -EINVAL;
1181-
1182-
spin_lock(&dev->count_lock);
1183-
if (dev->buf_use) {
1184-
spin_unlock(&dev->count_lock);
1185-
return -EBUSY;
1186-
}
1187-
atomic_inc(&dev->buf_alloc);
1188-
spin_unlock(&dev->count_lock);
1189-
1190-
mutex_lock(&dev->struct_mutex);
1191-
entry = &dma->bufs[order];
1192-
if (entry->buf_count) {
1193-
mutex_unlock(&dev->struct_mutex);
1194-
atomic_dec(&dev->buf_alloc);
1195-
return -ENOMEM; /* May only call once for each order */
1196-
}
1197-
1198-
if (count < 0 || count > 4096) {
1199-
mutex_unlock(&dev->struct_mutex);
1200-
atomic_dec(&dev->buf_alloc);
1201-
return -EINVAL;
1202-
}
1203-
1204-
entry->buflist = kzalloc(count * sizeof(*entry->buflist),
1205-
GFP_KERNEL);
1206-
if (!entry->buflist) {
1207-
mutex_unlock(&dev->struct_mutex);
1208-
atomic_dec(&dev->buf_alloc);
1209-
return -ENOMEM;
1210-
}
1211-
1212-
entry->buf_size = size;
1213-
entry->page_order = page_order;
1214-
1215-
offset = 0;
1216-
1217-
while (entry->buf_count < count) {
1218-
buf = &entry->buflist[entry->buf_count];
1219-
buf->idx = dma->buf_count + entry->buf_count;
1220-
buf->total = alignment;
1221-
buf->order = order;
1222-
buf->used = 0;
1223-
1224-
buf->offset = (dma->byte_count + offset);
1225-
buf->bus_address = agp_offset + offset;
1226-
buf->address = (void *)(agp_offset + offset);
1227-
buf->next = NULL;
1228-
buf->waiting = 0;
1229-
buf->pending = 0;
1230-
buf->file_priv = NULL;
1231-
1232-
buf->dev_priv_size = dev->driver->dev_priv_size;
1233-
buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
1234-
if (!buf->dev_private) {
1235-
/* Set count correctly so we free the proper amount. */
1236-
entry->buf_count = count;
1237-
drm_cleanup_buf_error(dev, entry);
1238-
mutex_unlock(&dev->struct_mutex);
1239-
atomic_dec(&dev->buf_alloc);
1240-
return -ENOMEM;
1241-
}
1242-
1243-
DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
1244-
1245-
offset += alignment;
1246-
entry->buf_count++;
1247-
byte_count += PAGE_SIZE << page_order;
1248-
}
1249-
1250-
DRM_DEBUG("byte_count: %d\n", byte_count);
1251-
1252-
temp_buflist = krealloc(dma->buflist,
1253-
(dma->buf_count + entry->buf_count) *
1254-
sizeof(*dma->buflist), GFP_KERNEL);
1255-
if (!temp_buflist) {
1256-
/* Free the entry because it isn't valid */
1257-
drm_cleanup_buf_error(dev, entry);
1258-
mutex_unlock(&dev->struct_mutex);
1259-
atomic_dec(&dev->buf_alloc);
1260-
return -ENOMEM;
1261-
}
1262-
dma->buflist = temp_buflist;
1263-
1264-
for (i = 0; i < entry->buf_count; i++) {
1265-
dma->buflist[i + dma->buf_count] = &entry->buflist[i];
1266-
}
1267-
1268-
dma->buf_count += entry->buf_count;
1269-
dma->seg_count += entry->seg_count;
1270-
dma->page_count += byte_count >> PAGE_SHIFT;
1271-
dma->byte_count += byte_count;
1272-
1273-
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1274-
DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1275-
1276-
mutex_unlock(&dev->struct_mutex);
1277-
1278-
request->count = entry->buf_count;
1279-
request->size = size;
1280-
1281-
dma->flags = _DRM_DMA_USE_FB;
1282-
1283-
atomic_dec(&dev->buf_alloc);
1284-
return 0;
1285-
}
1286-
1287-
12881133
/**
12891134
* Add buffers for DMA transfers (ioctl).
12901135
*
@@ -1319,7 +1164,7 @@ int drm_addbufs(struct drm_device *dev, void *data,
13191164
if (request->flags & _DRM_SG_BUFFER)
13201165
ret = drm_addbufs_sg(dev, request);
13211166
else if (request->flags & _DRM_FB_BUFFER)
1322-
ret = drm_addbufs_fb(dev, request);
1167+
ret = -EINVAL;
13231168
else
13241169
ret = drm_addbufs_pci(dev, request);
13251170

@@ -1556,9 +1401,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
15561401
if (request->count >= dma->buf_count) {
15571402
if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP))
15581403
|| (drm_core_check_feature(dev, DRIVER_SG)
1559-
&& (dma->flags & _DRM_DMA_USE_SG))
1560-
|| (drm_core_check_feature(dev, DRIVER_FB_DMA)
1561-
&& (dma->flags & _DRM_DMA_USE_FB))) {
1404+
&& (dma->flags & _DRM_DMA_USE_SG))) {
15621405
struct drm_local_map *map = dev->agp_buffer_map;
15631406
unsigned long token = dev->agp_buffer_token;
15641407

‎include/drm/drmP.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ int drm_err(const char *func, const char *format, ...);
147147
#define DRIVER_IRQ_SHARED 0x80
148148
#define DRIVER_IRQ_VBL 0x100
149149
#define DRIVER_DMA_QUEUE 0x200
150-
#define DRIVER_FB_DMA 0x400
151150
#define DRIVER_IRQ_VBL2 0x800
152151
#define DRIVER_GEM 0x1000
153152
#define DRIVER_MODESET 0x2000

0 commit comments

Comments
 (0)