Now that we have KMS, giving userland access to AGP through /dev/agp0
is no longer necessary. As far as I can tell none of the drivers we
ship in xenocara still use this. A possible exception is Intel's
first generation of integrated graphics (the i810 and i815 chipsets),
but I believe support for those has been broken for at least a year
now. And with the gutting of XAA from the X server the vesa driver
probably works as well as a dedicated driver for this hardware.
ok?
Index: arch/amd64/amd64/conf.c
===================================================================
RCS file: /home/cvs/src/sys/arch/amd64/amd64/conf.c,v
retrieving revision 1.44
diff -u -p -r1.44 conf.c
--- arch/amd64/amd64/conf.c 4 Nov 2013 17:14:26 -0000 1.44
+++ arch/amd64/amd64/conf.c 12 Mar 2014 15:06:54 -0000
@@ -156,8 +156,6 @@ cdev_decl(cztty);
#include "radio.h"
#include "nvram.h"
cdev_decl(nvram);
-#include "agp.h"
-cdev_decl(agp);
#include "drm.h"
cdev_decl(drm);
@@ -278,7 +276,7 @@ struct cdevsw cdevsw[] =
cdev_acpi_init(NACPI,acpi), /* 83: ACPI */
cdev_notdef(),
cdev_nvram_init(NNVRAM,nvram), /* 85: NVRAM interface */
- cdev_agp_init(NAGP,agp), /* 86: agp */
+ cdev_notdef(), /* 86 */
cdev_drm_init(NDRM,drm), /* 87: drm */
cdev_gpio_init(NGPIO,gpio), /* 88: gpio */
cdev_vscsi_init(NVSCSI,vscsi), /* 89: vscsi */
Index: arch/i386/i386/conf.c
===================================================================
RCS file: /home/cvs/src/sys/arch/i386/i386/conf.c,v
retrieving revision 1.145
diff -u -p -r1.145 conf.c
--- arch/i386/i386/conf.c 4 Nov 2013 14:11:29 -0000 1.145
+++ arch/i386/i386/conf.c 12 Mar 2014 15:06:03 -0000
@@ -159,8 +159,6 @@ cdev_decl(cztty);
#include "gpr.h"
#include "nvram.h"
cdev_decl(nvram);
-#include "agp.h"
-cdev_decl(agp);
#include "drm.h"
cdev_decl(drm);
@@ -283,7 +281,7 @@ struct cdevsw cdevsw[] =
cdev_nvram_init(NNVRAM,nvram), /* 84: NVRAM interface */
cdev_notdef(), /* 85: ACPI (deprecated) */
cdev_notdef(),
- cdev_agp_init(NAGP,agp), /* 87: agp */
+ cdev_notdef(), /* 87 */
cdev_drm_init(NDRM,drm), /* 88: drm */
cdev_amdmsr_init(NAMDMSR,amdmsr), /* 89: amdmsr */
cdev_vscsi_init(NVSCSI,vscsi), /* 90: vscsi */
Index: arch/macppc/macppc/conf.c
===================================================================
RCS file: /home/cvs/src/sys/arch/macppc/macppc/conf.c,v
retrieving revision 1.56
diff -u -p -r1.56 conf.c
--- arch/macppc/macppc/conf.c 4 Nov 2013 17:14:26 -0000 1.56
+++ arch/macppc/macppc/conf.c 12 Mar 2014 15:32:26 -0000
@@ -110,8 +110,6 @@ cdev_decl(com);
#include "inet.h"
#include "apm.h"
-#include "agp.h"
-cdev_decl(agp);
#include "drm.h"
cdev_decl(drm);
@@ -234,7 +232,7 @@ struct cdevsw cdevsw[] = {
cdev_vscsi_init(NVSCSI,vscsi), /* 83: vscsi */
cdev_disk_init(1,diskmap), /* 84: disk mapper */
cdev_pppx_init(NPPPX,pppx), /* 85: pppx */
- cdev_agp_init(NAGP,agp), /* 86: agp */
+ cdev_notdef, /* 86 */
cdev_drm_init(NDRM,drm), /* 87: drm */
cdev_fuse_init(NFUSE,fuse), /* 88: fuse */
};
Index: dev/pci/agp.c
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/agp.c,v
retrieving revision 1.38
diff -u -p -r1.38 agp.c
--- dev/pci/agp.c 6 Aug 2013 09:45:32 -0000 1.38
+++ dev/pci/agp.c 12 Mar 2014 14:35:25 -0000
@@ -68,14 +68,7 @@ int agpclose(dev_t, int, int , struct pr
struct agp_memory *agp_find_memory(struct agp_softc *, int);
struct agp_memory *agp_lookup_memory(struct agp_softc *, off_t);
-/* userland ioctl functions */
int agpvga_match(struct pci_attach_args *);
-int agp_info_user(void *, agp_info *);
-int agp_setup_user(void *, agp_setup *);
-int agp_allocate_user(void *, agp_allocate *);
-int agp_deallocate_user(void *, int);
-int agp_bind_user(void *, agp_bind *);
-int agp_unbind_user(void *, agp_unbind *);
int agp_acquire_helper(void *dev, enum agp_acquire_state state);
int agp_release_helper(void *dev, enum agp_acquire_state state);
@@ -208,101 +201,6 @@ struct cfdriver agp_cd = {
NULL, "agp", DV_DULL
};
-paddr_t
-agpmmap(dev_t dev, off_t off, int prot)
-{
- struct agp_softc *sc = agp_find_device(AGPUNIT(dev));
-
- if (sc == NULL)
- return (-1);
-
- return agp_mmap(sc, off, prot);
-}
-int
-agpopen(dev_t dev, int oflags, int devtype, struct proc *p)
-{
- struct agp_softc *sc = agp_find_device(AGPUNIT(dev));
-
- if (sc == NULL || sc->sc_chipc == NULL)
- return (ENXIO);
-
- if (!sc->sc_opened)
- sc->sc_opened = 1;
- else
- return (EBUSY);
-
- return (0);
-}
-
-
-int
-agpioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *pb)
-{
- struct agp_softc *sc = agp_find_device(AGPUNIT(dev));
-
- if (sc == NULL)
- return (ENODEV);
-
- if (sc->sc_methods == NULL || sc->sc_chipc == NULL)
- return (ENXIO);
-
- if (cmd != AGPIOC_INFO && !(flag & FWRITE))
- return (EPERM);
-
- switch(cmd) {
- case AGPIOC_INFO:
- return (agp_info_user(sc, (agp_info *)addr));
-
- case AGPIOC_ACQUIRE:
- return (agp_acquire_helper(sc, AGP_ACQUIRE_USER));
-
- case AGPIOC_RELEASE:
- return (agp_release_helper(sc, AGP_ACQUIRE_USER));
-
- case AGPIOC_SETUP:
- return (agp_setup_user(sc, (agp_setup *)addr));
-
- case AGPIOC_ALLOCATE:
- return (agp_allocate_user(sc, (agp_allocate *)addr));
-
- case AGPIOC_DEALLOCATE:
- return (agp_deallocate_user(sc, *(int *)addr));
-
- case AGPIOC_BIND:
- return (agp_bind_user(sc, (agp_bind *)addr));
-
- case AGPIOC_UNBIND:
- return (agp_unbind_user(sc, (agp_unbind *)addr));
-
- default:
- return (ENOTTY);
- }
-
-}
-
-int
-agpclose(dev_t dev, int flags, int devtype, struct proc *p)
-{
- struct agp_softc *sc = agp_find_device(AGPUNIT(dev));
- struct agp_memory *mem;
-
- /*
- * Clear the GATT and force release on last close
- */
- if (sc->sc_state == AGP_ACQUIRE_USER) {
- while ((mem = TAILQ_FIRST(&sc->sc_memory)) != 0) {
- if (mem->am_is_bound) {
- agp_unbind_memory(sc, mem);
- }
- agp_free_memory(sc, mem);
- }
- agp_release_helper(sc, AGP_ACQUIRE_USER);
- }
- sc->sc_opened = 0;
-
- return (0);
-}
-
struct agp_memory *
agp_find_memory(struct agp_softc *sc, int id)
{
@@ -695,96 +593,6 @@ agp_release_helper(void *dev, enum agp_a
}
sc->sc_state = AGP_ACQUIRE_FREE;
return (0);
-}
-
-/* Implementation of the userland ioctl API */
-
-int
-agp_info_user(void *dev, agp_info *info)
-{
- struct agp_softc *sc = (struct agp_softc *) dev;
-
- if (!sc->sc_chipc)
- return (ENXIO);
-
- bzero(info, sizeof *info);
- info->bridge_id = sc->sc_id;
- if (sc->sc_capoff != 0)
- info->agp_mode = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
- AGP_STATUS + sc->sc_capoff);
- else
- info->agp_mode = 0; /* i810 doesn't have real AGP */
- info->aper_base = sc->sc_apaddr;
- info->aper_size = sc->sc_apsize >> 20;
- info->pg_total =
- info->pg_system = sc->sc_maxmem >> AGP_PAGE_SHIFT;
- info->pg_used = sc->sc_allocated >> AGP_PAGE_SHIFT;
-
- return (0);
-}
-
-int
-agp_setup_user(void *dev, agp_setup *setup)
-{
- struct agp_softc *sc = dev;
-
- return (agp_enable(sc, setup->agp_mode));
-}
-
-int
-agp_allocate_user(void *dev, agp_allocate *alloc)
-{
- struct agp_softc *sc = dev;
- struct agp_memory *mem;
- size_t size = alloc->pg_count << AGP_PAGE_SHIFT;
-
- if (sc->sc_allocated + size > sc->sc_maxmem)
- return (EINVAL);
-
- mem = agp_alloc_memory(sc, alloc->type, size);
- if (mem) {
- alloc->key = mem->am_id;
- alloc->physical = mem->am_physical;
- return (0);
- } else
- return (ENOMEM);
-}
-
-int
-agp_deallocate_user(void *dev, int id)
-{
- struct agp_softc *sc = dev;
- struct agp_memory *mem;
-
- if ((mem = agp_find_memory(sc, id)) != NULL) {
- agp_free_memory(sc, mem);
- return (0);
- } else
- return (ENOENT);
-}
-
-int
-agp_bind_user(void *dev, agp_bind *bind)
-{
- struct agp_softc *sc = dev;
- struct agp_memory *mem;
-
- if ((mem = agp_find_memory(sc, bind->key)) == NULL)
- return (ENOENT);
- return (agp_bind_memory(sc, mem, bind->pg_start << AGP_PAGE_SHIFT));
-}
-
-
-int
-agp_unbind_user(void *dev, agp_unbind *unbind)
-{
- struct agp_softc *sc = dev;
- struct agp_memory *mem;
-
- if ((mem = agp_find_memory(sc, unbind->key)) == NULL)
- return (ENOENT);
-
- return (agp_unbind_memory(sc, mem));
}
/* Implementation of the kernel api */
Index: dev/pci/drm/drm_agpsupport.c
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/drm/drm_agpsupport.c,v
retrieving revision 1.25
diff -u -p -r1.25 drm_agpsupport.c
--- dev/pci/drm/drm_agpsupport.c 12 Aug 2013 04:11:52 -0000 1.25
+++ dev/pci/drm/drm_agpsupport.c 12 Mar 2014 15:03:34 -0000
@@ -30,18 +30,13 @@
*/
/*
- * Support code for tying the kernel AGP support to DRM drivers and
- * the DRM's AGP ioctls.
+ * Support code for tying the kernel AGP support to DRM drivers.
*/
#include "drmP.h"
#if __OS_HAS_AGP
-struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device *, void *);
-void drm_agp_remove_entry(struct drm_device *,
- struct drm_agp_mem *);
-
int
drm_agp_info(struct drm_device * dev, struct drm_agp_info *info)
{
@@ -66,22 +61,6 @@ drm_agp_info(struct drm_device * dev, st
}
int
-drm_agp_info_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_agp_info *info = data;
-
- return (drm_agp_info(dev, info));
-}
-
-int
-drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- return (drm_agp_acquire(dev));
-}
-
-int
drm_agp_acquire(struct drm_device *dev)
{
int retcode;
@@ -99,13 +78,6 @@ drm_agp_acquire(struct drm_device *dev)
}
int
-drm_agp_release_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- return (drm_agp_release(dev));
-}
-
-int
drm_agp_release(struct drm_device * dev)
{
if (dev->agp == NULL || !dev->agp->acquired)
@@ -130,224 +102,14 @@ drm_agp_enable(struct drm_device *dev, d
return (retcode);
}
-int
-drm_agp_enable_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_agp_mode *mode = data;
-
- return (drm_agp_enable(dev, *mode));
-}
-
-int
-drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
-{
- struct drm_agp_mem *entry;
- void *handle;
- struct agp_memory_info info;
- unsigned long pages;
- u_int32_t type;
-
- if (dev->agp == NULL || !dev->agp->acquired)
- return (EINVAL);
-
- entry = drm_alloc(sizeof(*entry));
- if (entry == NULL)
- return (ENOMEM);
-
- pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
- type = (u_int32_t)request->type;
-
- handle = agp_alloc_memory(dev->agp->agpdev, type,
- pages << AGP_PAGE_SHIFT);
- if (handle == NULL) {
- drm_free(entry);
- return (ENOMEM);
- }
-
- entry->handle = handle;
- entry->bound = 0;
- entry->pages = pages;
-
- agp_memory_info(dev->agp->agpdev, entry->handle, &info);
-
- request->handle = (unsigned long)entry->handle;
- request->physical = info.ami_physical;
- DRM_LOCK();
- TAILQ_INSERT_HEAD(&dev->agp->memory, entry, link);
- DRM_UNLOCK();
-
- return (0);
-}
-
-int
-drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_agp_buffer *request = data;
-
- return (drm_agp_alloc(dev, request));
-}
-
-/*
- * find entry on agp list. Must be called with dev_lock locked.
- */
-struct drm_agp_mem *
-drm_agp_lookup_entry(struct drm_device *dev, void *handle)
-{
- struct drm_agp_mem *entry;
-
- TAILQ_FOREACH(entry, &dev->agp->memory, link) {
- if (entry->handle == handle)
- break;
- }
- return (entry);
-}
-
-int
-drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
-{
- struct drm_agp_mem *entry;
- int retcode;
-
- if (dev->agp == NULL || !dev->agp->acquired)
- return (EINVAL);
-
- DRM_LOCK();
- entry = drm_agp_lookup_entry(dev, (void *)request->handle);
- /*
- * If the AGP bridge has an aperture base address of 0 and
- * the entry is bound with an offset of 0, entry->bound will
- * not reflect the reality.
- *
- * XXX This means that we may try to unbind unbound entries
- * with such an AGP bridge, but it should be safe because
- * agp_unbind_memory() has a correct check for bound memory.
- */
- if (entry == NULL || (!entry->bound && dev->agp->base)) {
- DRM_UNLOCK();
- return (EINVAL);
- }
-
- retcode = agp_unbind_memory(dev->agp->agpdev, entry->handle);
-
- if (retcode == 0)
- entry->bound = 0;
- DRM_UNLOCK();
-
- return (retcode);
-}
-
-int
-drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_agp_binding *request = data;
-
- return (drm_agp_unbind(dev, request));
-}
-
-int
-drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
-{
- struct drm_agp_mem *entry;
- int retcode, page;
-
- if (dev->agp == NULL || !dev->agp->acquired)
- return (EINVAL);
-
- DRM_DEBUG("agp_bind, page_size=%x\n", PAGE_SIZE);
-
- DRM_LOCK();
- entry = drm_agp_lookup_entry(dev, (void *)request->handle);
- if (entry == NULL || entry->bound) {
- DRM_UNLOCK();
- return (EINVAL);
- }
-
- page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
-
- retcode = agp_bind_memory(dev->agp->agpdev, entry->handle,
- page * PAGE_SIZE);
- if (retcode == 0)
- entry->bound = dev->agp->base + (page << PAGE_SHIFT);
- DRM_UNLOCK();
-
- return (retcode);
-}
-
-int
-drm_agp_bind_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_agp_binding *request = data;
-
- return (drm_agp_bind(dev, request));
-}
-
-/*
- * Remove entry from list and free. Call locked.
- */
-void
-drm_agp_remove_entry(struct drm_device *dev, struct drm_agp_mem *entry)
-{
- TAILQ_REMOVE(&dev->agp->memory, entry, link);
-
- if (entry->bound)
- agp_unbind_memory(dev->agp->agpdev, entry->handle);
- agp_free_memory(dev->agp->agpdev, entry->handle);
- drm_free(entry);
-}
-
void
drm_agp_takedown(struct drm_device *dev)
{
- struct drm_agp_mem *entry;
-
if (dev->agp == NULL)
return;
- /*
- * Remove AGP resources, but leave dev->agp intact until
- * we detach the device
- */
- DRM_LOCK();
- while ((entry = TAILQ_FIRST(&dev->agp->memory)) != NULL)
- drm_agp_remove_entry(dev, entry);
- DRM_UNLOCK();
-
drm_agp_release(dev);
dev->agp->enabled = 0;
-}
-
-int
-drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
-{
- struct drm_agp_mem *entry;
-
- if (dev->agp == NULL || !dev->agp->acquired)
- return (EINVAL);
-
- DRM_LOCK();
- entry = drm_agp_lookup_entry(dev, (void*)request->handle);
- if (entry == NULL) {
- DRM_UNLOCK();
- return (EINVAL);
- }
-
- drm_agp_remove_entry(dev, entry);
- DRM_UNLOCK();
-
- return (0);
-}
-
-int
-drm_agp_free_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_agp_buffer *request = data;
-
- return (drm_agp_free(dev, request));
}
struct drm_agp_head *
Index: sys/conf.h
===================================================================
RCS file: /home/cvs/src/sys/sys/conf.h,v
retrieving revision 1.126
diff -u -p -r1.126 conf.h
--- sys/conf.h 4 Nov 2013 14:07:15 -0000 1.126
+++ sys/conf.h 12 Mar 2014 14:23:01 -0000
@@ -474,13 +474,6 @@ extern struct cdevsw cdevsw[];
(dev_type_stop((*))) enodev, 0, selfalse, \
(dev_type_mmap((*))) enodev }
-/* open, close, ioctl, mmap */
-#define cdev_agp_init(c,n) { \
- dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
- (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
- (dev_type_stop((*))) enodev, 0, selfalse, \
- dev_init(c,n,mmap) }
-
/* open, close, read, ioctl, poll, mmap, nokqfilter */
#define cdev_drm_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c, n, read), \