Skip to content

Commit

Permalink
drm: Mark AGP implementation and ioctls as legacy
Browse files Browse the repository at this point in the history
Only UMs drivers use DRM's core AGP code and ioctls. Mark the icotls
as legacy. Add the _legacy_ infix to all AGP functions. Move the
declarations to the public and internal legacy header files. The agp
field in struct drm_device is now located in the structure's legacy
section. Adapt drivers to the changes.

AGP code now depends on CONFIG_DRM_LEGACY.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210507185709.22797-5-tzimmermann@suse.de
  • Loading branch information
Thomas Zimmermann committed May 10, 2021
1 parent 6bff227 commit 04dfe19
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 210 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ drm-y := drm_aperture.o drm_auth.o drm_cache.o \
drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \
drm_managed.o drm_vblank_work.o

drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_legacy_misc.o drm_lock.o \
drm_memory.o drm_scatter.o drm_vm.o
drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o drm_dma.o \
drm_legacy_misc.o drm_lock.o drm_memory.o drm_scatter.o \
drm_vm.o
drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
drm-$(CONFIG_COMPAT) += drm_ioc32.o
drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
drm-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_gem_shmem_helper.o
drm-$(CONFIG_DRM_PANEL) += drm_panel.o
drm-$(CONFIG_OF) += drm_of.o
drm-$(CONFIG_AGP) += drm_agpsupport.o
drm-$(CONFIG_PCI) += drm_pci.o
drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
Expand Down
99 changes: 51 additions & 48 deletions drivers/gpu/drm/drm_agpsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@

#include <asm/agp.h>

#include <drm/drm_agpsupport.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
#include <drm/drm_file.h>
#include <drm/drm_print.h>

#include "drm_legacy.h"

#if IS_ENABLED(CONFIG_AGP)

/*
* Get AGP information.
*
Expand All @@ -53,7 +54,7 @@
* Verifies the AGP device has been initialized and acquired and fills in the
* drm_agp_info structure with the information in drm_agp_head::agp_info.
*/
int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)
int drm_legacy_agp_info(struct drm_device *dev, struct drm_agp_info *info)
{
struct agp_kern_info *kern;

Expand All @@ -73,15 +74,15 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)

return 0;
}
EXPORT_SYMBOL(drm_agp_info);
EXPORT_SYMBOL(drm_legacy_agp_info);

int drm_agp_info_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_agp_info_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_agp_info *info = data;
int err;

err = drm_agp_info(dev, info);
err = drm_legacy_agp_info(dev, info);
if (err)
return err;

Expand All @@ -97,7 +98,7 @@ int drm_agp_info_ioctl(struct drm_device *dev, void *data,
* Verifies the AGP device hasn't been acquired before and calls
* \c agp_backend_acquire.
*/
int drm_agp_acquire(struct drm_device *dev)
int drm_legacy_agp_acquire(struct drm_device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev->dev);

Expand All @@ -111,7 +112,7 @@ int drm_agp_acquire(struct drm_device *dev)
dev->agp->acquired = 1;
return 0;
}
EXPORT_SYMBOL(drm_agp_acquire);
EXPORT_SYMBOL(drm_legacy_agp_acquire);

/*
* Acquire the AGP device (ioctl).
Expand All @@ -121,10 +122,10 @@ EXPORT_SYMBOL(drm_agp_acquire);
* Verifies the AGP device hasn't been acquired before and calls
* \c agp_backend_acquire.
*/
int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return drm_agp_acquire((struct drm_device *) file_priv->minor->dev);
return drm_legacy_agp_acquire((struct drm_device *)file_priv->minor->dev);
}

/*
Expand All @@ -135,20 +136,20 @@ int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
*
* Verifies the AGP device has been acquired and calls \c agp_backend_release.
*/
int drm_agp_release(struct drm_device *dev)
int drm_legacy_agp_release(struct drm_device *dev)
{
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
agp_backend_release(dev->agp->bridge);
dev->agp->acquired = 0;
return 0;
}
EXPORT_SYMBOL(drm_agp_release);
EXPORT_SYMBOL(drm_legacy_agp_release);

int drm_agp_release_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return drm_agp_release(dev);
return drm_legacy_agp_release(dev);
}

/*
Expand All @@ -161,7 +162,7 @@ int drm_agp_release_ioctl(struct drm_device *dev, void *data,
* Verifies the AGP device has been acquired but not enabled, and calls
* \c agp_enable.
*/
int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode)
int drm_legacy_agp_enable(struct drm_device *dev, struct drm_agp_mode mode)
{
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
Expand All @@ -171,14 +172,14 @@ int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode)
dev->agp->enabled = 1;
return 0;
}
EXPORT_SYMBOL(drm_agp_enable);
EXPORT_SYMBOL(drm_legacy_agp_enable);

int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_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);
return drm_legacy_agp_enable(dev, *mode);
}

/*
Expand All @@ -189,7 +190,7 @@ int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
* Verifies the AGP device is present and has been acquired, allocates the
* memory via agp_allocate_memory() and creates a drm_agp_mem entry for it.
*/
int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
int drm_legacy_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
{
struct drm_agp_mem *entry;
struct agp_memory *memory;
Expand Down Expand Up @@ -221,15 +222,15 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)

return 0;
}
EXPORT_SYMBOL(drm_agp_alloc);
EXPORT_SYMBOL(drm_legacy_agp_alloc);


int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
int drm_legacy_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);
return drm_legacy_agp_alloc(dev, request);
}

/*
Expand All @@ -241,8 +242,8 @@ int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
*
* Walks through drm_agp_head::memory until finding a matching handle.
*/
static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device *dev,
unsigned long handle)
static struct drm_agp_mem *drm_legacy_agp_lookup_entry(struct drm_device *dev,
unsigned long handle)
{
struct drm_agp_mem *entry;

Expand All @@ -261,30 +262,30 @@ static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device *dev,
* Verifies the AGP device is present and acquired, looks-up the AGP memory
* entry and passes it to the unbind_agp() function.
*/
int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
int drm_legacy_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
{
struct drm_agp_mem *entry;
int ret;

if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
entry = drm_agp_lookup_entry(dev, request->handle);
entry = drm_legacy_agp_lookup_entry(dev, request->handle);
if (!entry || !entry->bound)
return -EINVAL;
ret = agp_unbind_memory(entry->memory);
if (ret == 0)
entry->bound = 0;
return ret;
}
EXPORT_SYMBOL(drm_agp_unbind);
EXPORT_SYMBOL(drm_legacy_agp_unbind);


int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_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);
return drm_legacy_agp_unbind(dev, request);
}

/*
Expand All @@ -296,15 +297,15 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
* is currently bound into the GATT. Looks-up the AGP memory entry and passes
* it to bind_agp() function.
*/
int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
int drm_legacy_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
{
struct drm_agp_mem *entry;
int retcode;
int page;

if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
entry = drm_agp_lookup_entry(dev, request->handle);
entry = drm_legacy_agp_lookup_entry(dev, request->handle);
if (!entry || entry->bound)
return -EINVAL;
page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
Expand All @@ -316,15 +317,15 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
dev->agp->base, entry->bound);
return 0;
}
EXPORT_SYMBOL(drm_agp_bind);
EXPORT_SYMBOL(drm_legacy_agp_bind);


int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_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);
return drm_legacy_agp_bind(dev, request);
}

/*
Expand All @@ -337,13 +338,13 @@ int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
* unbind_agp(). Frees it via free_agp() as well as the entry itself
* and unlinks from the doubly linked list it's inserted in.
*/
int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
int drm_legacy_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
{
struct drm_agp_mem *entry;

if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
entry = drm_agp_lookup_entry(dev, request->handle);
entry = drm_legacy_agp_lookup_entry(dev, request->handle);
if (!entry)
return -EINVAL;
if (entry->bound)
Expand All @@ -355,15 +356,15 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
kfree(entry);
return 0;
}
EXPORT_SYMBOL(drm_agp_free);
EXPORT_SYMBOL(drm_legacy_agp_free);


int drm_agp_free_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
int drm_legacy_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);
return drm_legacy_agp_free(dev, request);
}

/*
Expand All @@ -378,7 +379,7 @@ int drm_agp_free_ioctl(struct drm_device *dev, void *data,
* Note that final cleanup of the kmalloced structure is directly done in
* drm_pci_agp_destroy.
*/
struct drm_agp_head *drm_agp_init(struct drm_device *dev)
struct drm_agp_head *drm_legacy_agp_init(struct drm_device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev->dev);
struct drm_agp_head *head = NULL;
Expand Down Expand Up @@ -409,7 +410,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
return head;
}
/* Only exported for i810.ko */
EXPORT_SYMBOL(drm_agp_init);
EXPORT_SYMBOL(drm_legacy_agp_init);

/**
* drm_legacy_agp_clear - Clear AGP resource list
Expand Down Expand Up @@ -439,8 +440,10 @@ void drm_legacy_agp_clear(struct drm_device *dev)
INIT_LIST_HEAD(&dev->agp->memory);

if (dev->agp->acquired)
drm_agp_release(dev);
drm_legacy_agp_release(dev);

dev->agp->acquired = 0;
dev->agp->enabled = 0;
}

#endif
1 change: 0 additions & 1 deletion drivers/gpu/drm/drm_bufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#include <asm/shmparam.h>

#include <drm/drm_agpsupport.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
#include <drm/drm_file.h>
Expand Down
Loading

0 comments on commit 04dfe19

Please sign in to comment.