* [PATCH 00/14] drm: Remove infrastructure for user-space mode setting
@ 2023-11-22 12:09 Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
` (15 more replies)
0 siblings, 16 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
The old drivers for user-space mode setting have been removed in Linux
v6.3. No one has complained or requested their return. It is time to
remove these drivers' infrastructure from the DRM core.
The recent Linux v6.6 has been designated as long-term release, [1] so
any remaining users have a few more years to get a new graphics card. The
legacy devices continue to be supported via simpledrm. Merging proper
drivers with kernel mode setting is also an option.
Patches 1 to 7 fix a few trivial issues that have been forgotten during
the removal of the drivers.
Patches 8 and 9 remove the leagcy ioctl interfaces. One op is different
from the others, so it gets its own patch.
Patches 10 to 12 remove the legacy source code from DRM. With that gone
patch 13, the AGP code can be simplified as well. There used to be
a device file for user-space mode setting, /dev/agpgart, that is now
obsolete.
Patch 14 removes the option from Kconfig.
[1] https://kernel.org/category/releases.html
Thomas Zimmermann (14):
arch/powerpc: Remove legacy DRM drivers from default configs
drm: Fix TODO list mentioning non-KMS drivers
drm: Include <drm/drm_auth.h>
drm/i915: Include <drm/drm_auth.h>
accel: Include <drm/drm_auth.h>
drm: Include <drm/drm_device.h>
drm/radeon: Do not include <drm/drm_legacy.h>
drm: Remove entry points for legacy ioctls
drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl
drm: Remove support for legacy drivers
drm: Remove locking for legacy ioctls and DRM_UNLOCKED
drm: Remove source code for non-KMS drivers
char/agp: Remove frontend code
drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY)
Documentation/gpu/todo.rst | 7 +-
arch/powerpc/configs/pmac32_defconfig | 2 -
arch/powerpc/configs/ppc6xx_defconfig | 7 -
drivers/accel/drm_accel.c | 1 +
drivers/char/agp/Makefile | 6 -
drivers/char/agp/agp.h | 9 -
drivers/char/agp/backend.c | 11 -
drivers/char/agp/compat_ioctl.c | 291 ---
drivers/char/agp/compat_ioctl.h | 106 --
drivers/char/agp/frontend.c | 1068 -----------
drivers/gpu/drm/Kconfig | 21 -
drivers/gpu/drm/Makefile | 12 -
drivers/gpu/drm/drm_agpsupport.c | 451 -----
drivers/gpu/drm/drm_auth.c | 8 +-
drivers/gpu/drm/drm_bufs.c | 1627 -----------------
drivers/gpu/drm/drm_context.c | 513 ------
drivers/gpu/drm/drm_dma.c | 178 --
drivers/gpu/drm/drm_drv.c | 17 -
drivers/gpu/drm/drm_file.c | 64 +-
drivers/gpu/drm/drm_hashtab.c | 203 --
drivers/gpu/drm/drm_internal.h | 7 -
drivers/gpu/drm/drm_ioc32.c | 613 +------
drivers/gpu/drm/drm_ioctl.c | 82 +-
drivers/gpu/drm/drm_irq.c | 204 ---
drivers/gpu/drm/drm_legacy.h | 290 ---
drivers/gpu/drm/drm_legacy_misc.c | 105 --
drivers/gpu/drm/drm_lock.c | 373 ----
drivers/gpu/drm/drm_memory.c | 138 --
drivers/gpu/drm/drm_pci.c | 204 +--
drivers/gpu/drm/drm_scatter.c | 220 ---
drivers/gpu/drm/drm_vblank.c | 101 -
drivers/gpu/drm/drm_vm.c | 665 -------
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
drivers/gpu/drm/radeon/radeon_drv.h | 1 -
include/drm/drm_auth.h | 22 -
include/drm/drm_device.h | 71 +-
include/drm/drm_drv.h | 19 -
include/drm/drm_file.h | 5 -
include/drm/drm_ioctl.h | 11 -
include/drm/drm_legacy.h | 331 ----
40 files changed, 20 insertions(+), 8045 deletions(-)
delete mode 100644 drivers/char/agp/compat_ioctl.c
delete mode 100644 drivers/char/agp/compat_ioctl.h
delete mode 100644 drivers/char/agp/frontend.c
delete mode 100644 drivers/gpu/drm/drm_agpsupport.c
delete mode 100644 drivers/gpu/drm/drm_bufs.c
delete mode 100644 drivers/gpu/drm/drm_context.c
delete mode 100644 drivers/gpu/drm/drm_dma.c
delete mode 100644 drivers/gpu/drm/drm_hashtab.c
delete mode 100644 drivers/gpu/drm/drm_irq.c
delete mode 100644 drivers/gpu/drm/drm_legacy.h
delete mode 100644 drivers/gpu/drm/drm_legacy_misc.c
delete mode 100644 drivers/gpu/drm/drm_lock.c
delete mode 100644 drivers/gpu/drm/drm_memory.c
delete mode 100644 drivers/gpu/drm/drm_scatter.c
delete mode 100644 drivers/gpu/drm/drm_vm.c
delete mode 100644 include/drm/drm_legacy.h
--
2.42.1
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
` (14 subsequent siblings)
15 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: dri-devel, Thomas Zimmermann, Daniel Vetter, Dave Airlie, stable
DRM drivers for user-space modesetting have been removed. Do not
select the respective options in the default configs.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
Cc: Cai Huoqing <cai.huoqing@linux.dev>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.3+
---
arch/powerpc/configs/pmac32_defconfig | 2 --
arch/powerpc/configs/ppc6xx_defconfig | 7 -------
2 files changed, 9 deletions(-)
diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
index 57ded82c28409..e41e7affd2482 100644
--- a/arch/powerpc/configs/pmac32_defconfig
+++ b/arch/powerpc/configs/pmac32_defconfig
@@ -188,8 +188,6 @@ CONFIG_AGP=m
CONFIG_AGP_UNINORTH=m
CONFIG_DRM=m
CONFIG_DRM_RADEON=m
-CONFIG_DRM_LEGACY=y
-CONFIG_DRM_R128=m
CONFIG_FB=y
CONFIG_FB_OF=y
CONFIG_FB_CONTROL=y
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index f279703425d45..e680cd086f0e8 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -678,13 +678,6 @@ CONFIG_AGP=y
CONFIG_AGP_UNINORTH=y
CONFIG_DRM=m
CONFIG_DRM_RADEON=m
-CONFIG_DRM_LEGACY=y
-CONFIG_DRM_TDFX=m
-CONFIG_DRM_R128=m
-CONFIG_DRM_MGA=m
-CONFIG_DRM_SIS=m
-CONFIG_DRM_VIA=m
-CONFIG_DRM_SAVAGE=m
CONFIG_FB=y
CONFIG_FB_CIRRUS=m
CONFIG_FB_OF=y
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs
@ 2023-11-22 12:09 ` Thomas Zimmermann
0 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Daniel Vetter, stable, Thomas Zimmermann, dri-devel, Dave Airlie
DRM drivers for user-space modesetting have been removed. Do not
select the respective options in the default configs.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
Cc: Cai Huoqing <cai.huoqing@linux.dev>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.3+
---
arch/powerpc/configs/pmac32_defconfig | 2 --
arch/powerpc/configs/ppc6xx_defconfig | 7 -------
2 files changed, 9 deletions(-)
diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
index 57ded82c28409..e41e7affd2482 100644
--- a/arch/powerpc/configs/pmac32_defconfig
+++ b/arch/powerpc/configs/pmac32_defconfig
@@ -188,8 +188,6 @@ CONFIG_AGP=m
CONFIG_AGP_UNINORTH=m
CONFIG_DRM=m
CONFIG_DRM_RADEON=m
-CONFIG_DRM_LEGACY=y
-CONFIG_DRM_R128=m
CONFIG_FB=y
CONFIG_FB_OF=y
CONFIG_FB_CONTROL=y
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index f279703425d45..e680cd086f0e8 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -678,13 +678,6 @@ CONFIG_AGP=y
CONFIG_AGP_UNINORTH=y
CONFIG_DRM=m
CONFIG_DRM_RADEON=m
-CONFIG_DRM_LEGACY=y
-CONFIG_DRM_TDFX=m
-CONFIG_DRM_R128=m
-CONFIG_DRM_MGA=m
-CONFIG_DRM_SIS=m
-CONFIG_DRM_VIA=m
-CONFIG_DRM_SAVAGE=m
CONFIG_FB=y
CONFIG_FB_CIRRUS=m
CONFIG_FB_OF=y
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 02/14] drm: Fix TODO list mentioning non-KMS drivers
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
` (14 subsequent siblings)
15 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: dri-devel, Thomas Zimmermann, Daniel Vetter, Dave Airlie,
Jonathan Corbet, stable, linux-doc
Non-KMS drivers have been removed from DRM. Update the TODO list
accordingly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
Cc: Cai Huoqing <cai.huoqing@linux.dev>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.3+
Cc: linux-doc@vger.kernel.org
---
Documentation/gpu/todo.rst | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index b62c7fa0c2bcc..3bdb8787960be 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -337,8 +337,8 @@ connector register/unregister fixes
Level: Intermediate
-Remove load/unload callbacks from all non-DRIVER_LEGACY drivers
----------------------------------------------------------------
+Remove load/unload callbacks
+----------------------------
The load/unload callbacks in struct &drm_driver are very much midlayers, plus
for historical reasons they get the ordering wrong (and we can't fix that)
@@ -347,8 +347,7 @@ between setting up the &drm_driver structure and calling drm_dev_register().
- Rework drivers to no longer use the load/unload callbacks, directly coding the
load/unload sequence into the driver's probe function.
-- Once all non-DRIVER_LEGACY drivers are converted, disallow the load/unload
- callbacks for all modern drivers.
+- Once all drivers are converted, remove the load/unload callbacks.
Contact: Daniel Vetter
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 02/14] drm: Fix TODO list mentioning non-KMS drivers
@ 2023-11-22 12:09 ` Thomas Zimmermann
0 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Jonathan Corbet, Daniel Vetter, linux-doc, stable, dri-devel,
Thomas Zimmermann, Dave Airlie
Non-KMS drivers have been removed from DRM. Update the TODO list
accordingly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
Cc: Cai Huoqing <cai.huoqing@linux.dev>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.3+
Cc: linux-doc@vger.kernel.org
---
Documentation/gpu/todo.rst | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index b62c7fa0c2bcc..3bdb8787960be 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -337,8 +337,8 @@ connector register/unregister fixes
Level: Intermediate
-Remove load/unload callbacks from all non-DRIVER_LEGACY drivers
----------------------------------------------------------------
+Remove load/unload callbacks
+----------------------------
The load/unload callbacks in struct &drm_driver are very much midlayers, plus
for historical reasons they get the ordering wrong (and we can't fix that)
@@ -347,8 +347,7 @@ between setting up the &drm_driver structure and calling drm_dev_register().
- Rework drivers to no longer use the load/unload callbacks, directly coding the
load/unload sequence into the driver's probe function.
-- Once all non-DRIVER_LEGACY drivers are converted, disallow the load/unload
- callbacks for all modern drivers.
+- Once all drivers are converted, remove the load/unload callbacks.
Contact: Daniel Vetter
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 03/14] drm: Include <drm/drm_auth.h>
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-22 12:09 ` Thomas Zimmermann
` (12 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
which will be removed. Include drm_auth.h directly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_pci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 39d35fc3a43bc..67907dd427214 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -29,6 +29,7 @@
#include <linux/pci.h>
#include <linux/slab.h>
+#include <drm/drm_auth.h>
#include <drm/drm.h>
#include <drm/drm_drv.h>
#include <drm/drm_print.h>
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Intel-gfx] [PATCH 04/14] drm/i915: Include <drm/drm_auth.h>
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
` (14 subsequent siblings)
15 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: intel-gfx, dri-devel, Thomas Zimmermann, Rodrigo Vivi
One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
which will be removed. Include drm_auth.h directly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
---
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index b1aa62dfb155d..81a57dd52dfda 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -9,6 +9,7 @@
#include <linux/sync_file.h>
#include <linux/uaccess.h>
+#include <drm/drm_auth.h>
#include <drm/drm_syncobj.h>
#include "display/intel_frontbuffer.h"
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 04/14] drm/i915: Include <drm/drm_auth.h>
@ 2023-11-22 12:09 ` Thomas Zimmermann
0 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Tvrtko Ursulin, intel-gfx, dri-devel, Thomas Zimmermann,
Rodrigo Vivi
One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
which will be removed. Include drm_auth.h directly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
---
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index b1aa62dfb155d..81a57dd52dfda 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -9,6 +9,7 @@
#include <linux/sync_file.h>
#include <linux/uaccess.h>
+#include <drm/drm_auth.h>
#include <drm/drm_syncobj.h>
#include "display/intel_frontbuffer.h"
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 05/14] accel: Include <drm/drm_auth.h>
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (3 preceding siblings ...)
2023-11-22 12:09 ` Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 06/14] drm: Include <drm/drm_device.h> Thomas Zimmermann
` (10 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Oded Gabbay, Thomas Zimmermann, dri-devel
One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
which will be removed. Include drm_auth.h directly.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Oded Gabbay <ogabbay@kernel.org>
---
drivers/accel/drm_accel.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/accel/drm_accel.c b/drivers/accel/drm_accel.c
index 294b572a9c331..24cac4c0274bb 100644
--- a/drivers/accel/drm_accel.c
+++ b/drivers/accel/drm_accel.c
@@ -11,6 +11,7 @@
#include <linux/idr.h>
#include <drm/drm_accel.h>
+#include <drm/drm_auth.h>
#include <drm/drm_debugfs.h>
#include <drm/drm_drv.h>
#include <drm/drm_file.h>
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 06/14] drm: Include <drm/drm_device.h>
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (4 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 05/14] accel: " Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-22 12:09 ` [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h> Thomas Zimmermann
` (9 subsequent siblings)
15 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
Include <drm/drm_device.h> in drm_ioc32.c. Resolves a depenency
on <drm/drm_legacy.h>, which will be removed.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_ioc32.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 025dc558c94ee..c0163cb076ad8 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -31,6 +31,7 @@
#include <linux/ratelimit.h>
#include <linux/export.h>
+#include <drm/drm_device.h>
#include <drm/drm_file.h>
#include <drm/drm_print.h>
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h>
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (5 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 06/14] drm: Include <drm/drm_device.h> Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:00 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 08/14] drm: Remove entry points for legacy ioctls Thomas Zimmermann
` (8 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Pan, Xinhui, amd-gfx, dri-devel, Thomas Zimmermann, Alex Deucher,
Christian König
Including <drm/drm_legacy.h> is not required by radeon.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
drivers/gpu/drm/radeon/radeon_drv.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 34a1c73d3938f..02a65971d140d 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -33,7 +33,6 @@
#include <linux/firmware.h>
#include <linux/platform_device.h>
-#include <drm/drm_legacy.h>
#include "radeon_family.h"
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 08/14] drm: Remove entry points for legacy ioctls
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (6 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h> Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:04 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl Thomas Zimmermann
` (7 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
DRM drivers with user-space mode setting have been removed in Linux
v6.3. [1] Now remove the ioctl entry points for these drivers. Invoking
any of the ioctl ops will unconditionally return -EINVAL to user space.
This has already been the behavior for kernels without CONFIG_DRM_LEGACY
set.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/series/111602/ # [1]
---
drivers/gpu/drm/drm_ioc32.c | 610 ------------------------------------
drivers/gpu/drm/drm_ioctl.c | 57 ----
2 files changed, 667 deletions(-)
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index c0163cb076ad8..910cadf14756e 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -37,7 +37,6 @@
#include "drm_crtc_internal.h"
#include "drm_internal.h"
-#include "drm_legacy.h"
#define DRM_IOCTL_VERSION32 DRM_IOWR(0x00, drm_version32_t)
#define DRM_IOCTL_GET_UNIQUE32 DRM_IOWR(0x01, drm_unique32_t)
@@ -164,92 +163,6 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
return -EINVAL;
}
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-typedef struct drm_map32 {
- u32 offset; /* Requested physical address (0 for SAREA) */
- u32 size; /* Requested physical size (bytes) */
- enum drm_map_type type; /* Type of memory to map */
- enum drm_map_flags flags; /* Flags */
- u32 handle; /* User-space: "Handle" to pass to mmap() */
- int mtrr; /* MTRR slot used */
-} drm_map32_t;
-
-static int compat_drm_getmap(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_map32_t __user *argp = (void __user *)arg;
- drm_map32_t m32;
- struct drm_map map;
- int err;
-
- if (copy_from_user(&m32, argp, sizeof(m32)))
- return -EFAULT;
-
- map.offset = m32.offset;
- err = drm_ioctl_kernel(file, drm_legacy_getmap_ioctl, &map, 0);
- if (err)
- return err;
-
- m32.offset = map.offset;
- m32.size = map.size;
- m32.type = map.type;
- m32.flags = map.flags;
- m32.handle = ptr_to_compat((void __user *)map.handle);
- m32.mtrr = map.mtrr;
- if (copy_to_user(argp, &m32, sizeof(m32)))
- return -EFAULT;
- return 0;
-
-}
-
-static int compat_drm_addmap(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_map32_t __user *argp = (void __user *)arg;
- drm_map32_t m32;
- struct drm_map map;
- int err;
-
- if (copy_from_user(&m32, argp, sizeof(m32)))
- return -EFAULT;
-
- map.offset = m32.offset;
- map.size = m32.size;
- map.type = m32.type;
- map.flags = m32.flags;
-
- err = drm_ioctl_kernel(file, drm_legacy_addmap_ioctl, &map,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
- if (err)
- return err;
-
- m32.offset = map.offset;
- m32.mtrr = map.mtrr;
- m32.handle = ptr_to_compat((void __user *)map.handle);
- if (map.handle != compat_ptr(m32.handle))
- pr_err_ratelimited("compat_drm_addmap truncated handle %p for type %d offset %x\n",
- map.handle, m32.type, m32.offset);
-
- if (copy_to_user(argp, &m32, sizeof(m32)))
- return -EFAULT;
-
- return 0;
-}
-
-static int compat_drm_rmmap(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_map32_t __user *argp = (void __user *)arg;
- struct drm_map map;
- u32 handle;
-
- if (get_user(handle, &argp->handle))
- return -EFAULT;
- map.handle = compat_ptr(handle);
- return drm_ioctl_kernel(file, drm_legacy_rmmap_ioctl, &map, DRM_AUTH);
-}
-#endif
-
typedef struct drm_client32 {
int idx; /* Which client desired? */
int auth; /* Is client authenticated? */
@@ -309,501 +222,6 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
return 0;
}
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-typedef struct drm_buf_desc32 {
- int count; /* Number of buffers of this size */
- int size; /* Size in bytes */
- int low_mark; /* Low water mark */
- int high_mark; /* High water mark */
- int flags;
- u32 agp_start; /* Start address in the AGP aperture */
-} drm_buf_desc32_t;
-
-static int compat_drm_addbufs(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_buf_desc32_t __user *argp = (void __user *)arg;
- drm_buf_desc32_t desc32;
- struct drm_buf_desc desc;
- int err;
-
- if (copy_from_user(&desc32, argp, sizeof(drm_buf_desc32_t)))
- return -EFAULT;
-
- desc = (struct drm_buf_desc){
- desc32.count, desc32.size, desc32.low_mark, desc32.high_mark,
- desc32.flags, desc32.agp_start
- };
-
- err = drm_ioctl_kernel(file, drm_legacy_addbufs, &desc,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
- if (err)
- return err;
-
- desc32 = (drm_buf_desc32_t){
- desc.count, desc.size, desc.low_mark, desc.high_mark,
- desc.flags, desc.agp_start
- };
- if (copy_to_user(argp, &desc32, sizeof(drm_buf_desc32_t)))
- return -EFAULT;
-
- return 0;
-}
-
-static int compat_drm_markbufs(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_buf_desc32_t b32;
- drm_buf_desc32_t __user *argp = (void __user *)arg;
- struct drm_buf_desc buf;
-
- if (copy_from_user(&b32, argp, sizeof(b32)))
- return -EFAULT;
-
- buf.size = b32.size;
- buf.low_mark = b32.low_mark;
- buf.high_mark = b32.high_mark;
-
- return drm_ioctl_kernel(file, drm_legacy_markbufs, &buf,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-
-typedef struct drm_buf_info32 {
- int count; /**< Entries in list */
- u32 list;
-} drm_buf_info32_t;
-
-static int copy_one_buf32(void *data, int count, struct drm_buf_entry *from)
-{
- drm_buf_info32_t *request = data;
- drm_buf_desc32_t __user *to = compat_ptr(request->list);
- drm_buf_desc32_t v = {.count = from->buf_count,
- .size = from->buf_size,
- .low_mark = from->low_mark,
- .high_mark = from->high_mark};
-
- if (copy_to_user(to + count, &v, offsetof(drm_buf_desc32_t, flags)))
- return -EFAULT;
- return 0;
-}
-
-static int drm_legacy_infobufs32(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- drm_buf_info32_t *request = data;
-
- return __drm_legacy_infobufs(dev, data, &request->count, copy_one_buf32);
-}
-
-static int compat_drm_infobufs(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_buf_info32_t req32;
- drm_buf_info32_t __user *argp = (void __user *)arg;
- int err;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
-
- if (req32.count < 0)
- req32.count = 0;
-
- err = drm_ioctl_kernel(file, drm_legacy_infobufs32, &req32, DRM_AUTH);
- if (err)
- return err;
-
- if (put_user(req32.count, &argp->count))
- return -EFAULT;
-
- return 0;
-}
-
-typedef struct drm_buf_pub32 {
- int idx; /**< Index into the master buffer list */
- int total; /**< Buffer size */
- int used; /**< Amount of buffer in use (for DMA) */
- u32 address; /**< Address of buffer */
-} drm_buf_pub32_t;
-
-typedef struct drm_buf_map32 {
- int count; /**< Length of the buffer list */
- u32 virtual; /**< Mmap'd area in user-virtual */
- u32 list; /**< Buffer information */
-} drm_buf_map32_t;
-
-static int map_one_buf32(void *data, int idx, unsigned long virtual,
- struct drm_buf *buf)
-{
- drm_buf_map32_t *request = data;
- drm_buf_pub32_t __user *to = compat_ptr(request->list) + idx;
- drm_buf_pub32_t v;
-
- v.idx = buf->idx;
- v.total = buf->total;
- v.used = 0;
- v.address = virtual + buf->offset;
- if (copy_to_user(to, &v, sizeof(v)))
- return -EFAULT;
- return 0;
-}
-
-static int drm_legacy_mapbufs32(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- drm_buf_map32_t *request = data;
- void __user *v;
- int err = __drm_legacy_mapbufs(dev, data, &request->count,
- &v, map_one_buf32,
- file_priv);
- request->virtual = ptr_to_compat(v);
- return err;
-}
-
-static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_buf_map32_t __user *argp = (void __user *)arg;
- drm_buf_map32_t req32;
- int err;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
- if (req32.count < 0)
- return -EINVAL;
-
- err = drm_ioctl_kernel(file, drm_legacy_mapbufs32, &req32, DRM_AUTH);
- if (err)
- return err;
-
- if (put_user(req32.count, &argp->count)
- || put_user(req32.virtual, &argp->virtual))
- return -EFAULT;
-
- return 0;
-}
-
-typedef struct drm_buf_free32 {
- int count;
- u32 list;
-} drm_buf_free32_t;
-
-static int compat_drm_freebufs(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_buf_free32_t req32;
- struct drm_buf_free request;
- drm_buf_free32_t __user *argp = (void __user *)arg;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
-
- request.count = req32.count;
- request.list = compat_ptr(req32.list);
- return drm_ioctl_kernel(file, drm_legacy_freebufs, &request, DRM_AUTH);
-}
-
-typedef struct drm_ctx_priv_map32 {
- unsigned int ctx_id; /**< Context requesting private mapping */
- u32 handle; /**< Handle of map */
-} drm_ctx_priv_map32_t;
-
-static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_ctx_priv_map32_t req32;
- struct drm_ctx_priv_map request;
- drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
-
- request.ctx_id = req32.ctx_id;
- request.handle = compat_ptr(req32.handle);
- return drm_ioctl_kernel(file, drm_legacy_setsareactx, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-
-static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- struct drm_ctx_priv_map req;
- drm_ctx_priv_map32_t req32;
- drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
- int err;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
-
- req.ctx_id = req32.ctx_id;
- err = drm_ioctl_kernel(file, drm_legacy_getsareactx, &req, DRM_AUTH);
- if (err)
- return err;
-
- req32.handle = ptr_to_compat((void __user *)req.handle);
- if (copy_to_user(argp, &req32, sizeof(req32)))
- return -EFAULT;
-
- return 0;
-}
-
-typedef struct drm_ctx_res32 {
- int count;
- u32 contexts;
-} drm_ctx_res32_t;
-
-static int compat_drm_resctx(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_ctx_res32_t __user *argp = (void __user *)arg;
- drm_ctx_res32_t res32;
- struct drm_ctx_res res;
- int err;
-
- if (copy_from_user(&res32, argp, sizeof(res32)))
- return -EFAULT;
-
- res.count = res32.count;
- res.contexts = compat_ptr(res32.contexts);
- err = drm_ioctl_kernel(file, drm_legacy_resctx, &res, DRM_AUTH);
- if (err)
- return err;
-
- res32.count = res.count;
- if (copy_to_user(argp, &res32, sizeof(res32)))
- return -EFAULT;
-
- return 0;
-}
-
-typedef struct drm_dma32 {
- int context; /**< Context handle */
- int send_count; /**< Number of buffers to send */
- u32 send_indices; /**< List of handles to buffers */
- u32 send_sizes; /**< Lengths of data to send */
- enum drm_dma_flags flags; /**< Flags */
- int request_count; /**< Number of buffers requested */
- int request_size; /**< Desired size for buffers */
- u32 request_indices; /**< Buffer information */
- u32 request_sizes;
- int granted_count; /**< Number of buffers granted */
-} drm_dma32_t;
-
-static int compat_drm_dma(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_dma32_t d32;
- drm_dma32_t __user *argp = (void __user *)arg;
- struct drm_dma d;
- int err;
-
- if (copy_from_user(&d32, argp, sizeof(d32)))
- return -EFAULT;
-
- d.context = d32.context;
- d.send_count = d32.send_count;
- d.send_indices = compat_ptr(d32.send_indices);
- d.send_sizes = compat_ptr(d32.send_sizes);
- d.flags = d32.flags;
- d.request_count = d32.request_count;
- d.request_indices = compat_ptr(d32.request_indices);
- d.request_sizes = compat_ptr(d32.request_sizes);
- err = drm_ioctl_kernel(file, drm_legacy_dma_ioctl, &d, DRM_AUTH);
- if (err)
- return err;
-
- if (put_user(d.request_size, &argp->request_size)
- || put_user(d.granted_count, &argp->granted_count))
- return -EFAULT;
-
- return 0;
-}
-#endif
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-#if IS_ENABLED(CONFIG_AGP)
-typedef struct drm_agp_mode32 {
- u32 mode; /**< AGP mode */
-} drm_agp_mode32_t;
-
-static int compat_drm_agp_enable(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_agp_mode32_t __user *argp = (void __user *)arg;
- struct drm_agp_mode mode;
-
- if (get_user(mode.mode, &argp->mode))
- return -EFAULT;
-
- return drm_ioctl_kernel(file, drm_legacy_agp_enable_ioctl, &mode,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-
-typedef struct drm_agp_info32 {
- int agp_version_major;
- int agp_version_minor;
- u32 mode;
- u32 aperture_base; /* physical address */
- u32 aperture_size; /* bytes */
- u32 memory_allowed; /* bytes */
- u32 memory_used;
-
- /* PCI information */
- unsigned short id_vendor;
- unsigned short id_device;
-} drm_agp_info32_t;
-
-static int compat_drm_agp_info(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_agp_info32_t __user *argp = (void __user *)arg;
- drm_agp_info32_t i32;
- struct drm_agp_info info;
- int err;
-
- err = drm_ioctl_kernel(file, drm_legacy_agp_info_ioctl, &info, DRM_AUTH);
- if (err)
- return err;
-
- i32.agp_version_major = info.agp_version_major;
- i32.agp_version_minor = info.agp_version_minor;
- i32.mode = info.mode;
- i32.aperture_base = info.aperture_base;
- i32.aperture_size = info.aperture_size;
- i32.memory_allowed = info.memory_allowed;
- i32.memory_used = info.memory_used;
- i32.id_vendor = info.id_vendor;
- i32.id_device = info.id_device;
- if (copy_to_user(argp, &i32, sizeof(i32)))
- return -EFAULT;
-
- return 0;
-}
-
-typedef struct drm_agp_buffer32 {
- u32 size; /**< In bytes -- will round to page boundary */
- u32 handle; /**< Used for binding / unbinding */
- u32 type; /**< Type of memory to allocate */
- u32 physical; /**< Physical used by i810 */
-} drm_agp_buffer32_t;
-
-static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_agp_buffer32_t __user *argp = (void __user *)arg;
- drm_agp_buffer32_t req32;
- struct drm_agp_buffer request;
- int err;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
-
- request.size = req32.size;
- request.type = req32.type;
- err = drm_ioctl_kernel(file, drm_legacy_agp_alloc_ioctl, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
- if (err)
- return err;
-
- req32.handle = request.handle;
- req32.physical = request.physical;
- if (copy_to_user(argp, &req32, sizeof(req32))) {
- drm_ioctl_kernel(file, drm_legacy_agp_free_ioctl, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
- return -EFAULT;
- }
-
- return 0;
-}
-
-static int compat_drm_agp_free(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_agp_buffer32_t __user *argp = (void __user *)arg;
- struct drm_agp_buffer request;
-
- if (get_user(request.handle, &argp->handle))
- return -EFAULT;
-
- return drm_ioctl_kernel(file, drm_legacy_agp_free_ioctl, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-
-typedef struct drm_agp_binding32 {
- u32 handle; /**< From drm_agp_buffer */
- u32 offset; /**< In bytes -- will round to page boundary */
-} drm_agp_binding32_t;
-
-static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_agp_binding32_t __user *argp = (void __user *)arg;
- drm_agp_binding32_t req32;
- struct drm_agp_binding request;
-
- if (copy_from_user(&req32, argp, sizeof(req32)))
- return -EFAULT;
-
- request.handle = req32.handle;
- request.offset = req32.offset;
- return drm_ioctl_kernel(file, drm_legacy_agp_bind_ioctl, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-
-static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_agp_binding32_t __user *argp = (void __user *)arg;
- struct drm_agp_binding request;
-
- if (get_user(request.handle, &argp->handle))
- return -EFAULT;
-
- return drm_ioctl_kernel(file, drm_legacy_agp_unbind_ioctl, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-#endif /* CONFIG_AGP */
-
-typedef struct drm_scatter_gather32 {
- u32 size; /**< In bytes -- will round to page boundary */
- u32 handle; /**< Used for mapping / unmapping */
-} drm_scatter_gather32_t;
-
-static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_scatter_gather32_t __user *argp = (void __user *)arg;
- struct drm_scatter_gather request;
- int err;
-
- if (get_user(request.size, &argp->size))
- return -EFAULT;
-
- err = drm_ioctl_kernel(file, drm_legacy_sg_alloc, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
- if (err)
- return err;
-
- /* XXX not sure about the handle conversion here... */
- if (put_user(request.handle >> PAGE_SHIFT, &argp->handle))
- return -EFAULT;
-
- return 0;
-}
-
-static int compat_drm_sg_free(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- drm_scatter_gather32_t __user *argp = (void __user *)arg;
- struct drm_scatter_gather request;
- unsigned long x;
-
- if (get_user(x, &argp->handle))
- return -EFAULT;
- request.handle = x << PAGE_SHIFT;
- return drm_ioctl_kernel(file, drm_legacy_sg_free, &request,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
-}
-#endif
#if defined(CONFIG_X86)
typedef struct drm_update_draw32 {
drm_drawable_t handle;
@@ -915,37 +333,9 @@ static struct {
#define DRM_IOCTL32_DEF(n, f) [DRM_IOCTL_NR(n##32)] = {.fn = f, .name = #n}
DRM_IOCTL32_DEF(DRM_IOCTL_VERSION, compat_drm_version),
DRM_IOCTL32_DEF(DRM_IOCTL_GET_UNIQUE, compat_drm_getunique),
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- DRM_IOCTL32_DEF(DRM_IOCTL_GET_MAP, compat_drm_getmap),
-#endif
DRM_IOCTL32_DEF(DRM_IOCTL_GET_CLIENT, compat_drm_getclient),
DRM_IOCTL32_DEF(DRM_IOCTL_GET_STATS, compat_drm_getstats),
DRM_IOCTL32_DEF(DRM_IOCTL_SET_UNIQUE, compat_drm_setunique),
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- DRM_IOCTL32_DEF(DRM_IOCTL_ADD_MAP, compat_drm_addmap),
- DRM_IOCTL32_DEF(DRM_IOCTL_ADD_BUFS, compat_drm_addbufs),
- DRM_IOCTL32_DEF(DRM_IOCTL_MARK_BUFS, compat_drm_markbufs),
- DRM_IOCTL32_DEF(DRM_IOCTL_INFO_BUFS, compat_drm_infobufs),
- DRM_IOCTL32_DEF(DRM_IOCTL_MAP_BUFS, compat_drm_mapbufs),
- DRM_IOCTL32_DEF(DRM_IOCTL_FREE_BUFS, compat_drm_freebufs),
- DRM_IOCTL32_DEF(DRM_IOCTL_RM_MAP, compat_drm_rmmap),
- DRM_IOCTL32_DEF(DRM_IOCTL_SET_SAREA_CTX, compat_drm_setsareactx),
- DRM_IOCTL32_DEF(DRM_IOCTL_GET_SAREA_CTX, compat_drm_getsareactx),
- DRM_IOCTL32_DEF(DRM_IOCTL_RES_CTX, compat_drm_resctx),
- DRM_IOCTL32_DEF(DRM_IOCTL_DMA, compat_drm_dma),
-#if IS_ENABLED(CONFIG_AGP)
- DRM_IOCTL32_DEF(DRM_IOCTL_AGP_ENABLE, compat_drm_agp_enable),
- DRM_IOCTL32_DEF(DRM_IOCTL_AGP_INFO, compat_drm_agp_info),
- DRM_IOCTL32_DEF(DRM_IOCTL_AGP_ALLOC, compat_drm_agp_alloc),
- DRM_IOCTL32_DEF(DRM_IOCTL_AGP_FREE, compat_drm_agp_free),
- DRM_IOCTL32_DEF(DRM_IOCTL_AGP_BIND, compat_drm_agp_bind),
- DRM_IOCTL32_DEF(DRM_IOCTL_AGP_UNBIND, compat_drm_agp_unbind),
-#endif
-#endif
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- DRM_IOCTL32_DEF(DRM_IOCTL_SG_ALLOC, compat_drm_sg_alloc),
- DRM_IOCTL32_DEF(DRM_IOCTL_SG_FREE, compat_drm_sg_free),
-#endif
#if defined(CONFIG_X86)
DRM_IOCTL32_DEF(DRM_IOCTL_UPDATE_DRAW, compat_drm_update_draw),
#endif
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 44fda68c28aeb..e6c32f76c7452 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -42,7 +42,6 @@
#include "drm_crtc_internal.h"
#include "drm_internal.h"
-#include "drm_legacy.h"
/**
* DOC: getunique and setversion story
@@ -559,21 +558,11 @@ static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
.name = #ioctl \
}
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-#define DRM_LEGACY_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(ioctl, _func, _flags)
-#else
-#define DRM_LEGACY_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(ioctl, drm_invalid_op, _flags)
-#endif
-
/* Ioctl table */
static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_legacy_irq_by_busid,
- DRM_MASTER|DRM_ROOT_ONLY),
-
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0),
@@ -586,60 +575,14 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_MASTER),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_legacy_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_legacy_rmmap_ioctl, DRM_AUTH),
-
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_legacy_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_legacy_getsareactx, DRM_AUTH),
-
DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, 0),
DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, 0),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_legacy_addctx, DRM_AUTH|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_legacy_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_legacy_getctx, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_legacy_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_legacy_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_legacy_resctx, DRM_AUTH),
-
DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_LOCK, drm_legacy_lock, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_legacy_unlock, DRM_AUTH),
-
DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_legacy_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_legacy_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_legacy_infobufs, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_legacy_mapbufs, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_legacy_freebufs, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_DMA, drm_legacy_dma_ioctl, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_legacy_irq_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-
-#if IS_ENABLED(CONFIG_AGP)
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_legacy_agp_acquire_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_legacy_agp_release_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_legacy_agp_enable_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_legacy_agp_info_ioctl, DRM_AUTH),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_legacy_agp_alloc_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_legacy_agp_free_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_legacy_agp_bind_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_legacy_agp_unbind_ioctl,
- DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-#endif
-
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_legacy_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_legacy_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-
DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_legacy_modeset_ctl_ioctl, 0),
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (7 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 08/14] drm: Remove entry points for legacy ioctls Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 10/14] drm: Remove support for legacy drivers Thomas Zimmermann
` (6 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
DRM drivers with user-space mode setting have been removed in Linux
v6.3. [1] Now remove the ioctl entry points for these drivers. Invoking
any of the ioctl ops will unconditionally return -EINVAL to user space.
Invoking DRM_IOCTL_MODESET_CTL is different from the other legacy
ioctl ops as it returns 0 even without CONFIG_DRM_LEGACY set. From the
original commit 29935554b384 ("drm: Disallow DRM_IOCTL_MODESET_CTL for
KMS drivers") it is not apparent how or why the operation differs from
the others. It is likely just an oversight in commit 61ae227032e7
("drm: allow removal of legacy codepaths (v4.1)"), which allowed
disabling leagacy ioctls in the first place. Still keep this removal
separate from the other ioctls to allow an easy revert, if necessary.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/series/111602/ # [1]
---
drivers/gpu/drm/drm_internal.h | 2 -
drivers/gpu/drm/drm_ioctl.c | 2 -
drivers/gpu/drm/drm_vblank.c | 82 ----------------------------------
3 files changed, 86 deletions(-)
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index b12c463bc4605..a538a48c7d952 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -117,8 +117,6 @@ void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
/* IOCTLS */
int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp);
-int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
/* drm_irq.c */
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index e6c32f76c7452..9c6326b908e74 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -585,8 +585,6 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_legacy_modeset_ctl_ioctl, 0),
-
DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_RENDER_ALLOW),
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 877e2067534fa..a11f164b2384f 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -1574,88 +1574,6 @@ void drm_crtc_vblank_restore(struct drm_crtc *crtc)
}
EXPORT_SYMBOL(drm_crtc_vblank_restore);
-static void drm_legacy_vblank_pre_modeset(struct drm_device *dev,
- unsigned int pipe)
-{
- struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
-
- /* vblank is not initialized (IRQ not installed ?), or has been freed */
- if (!drm_dev_has_vblank(dev))
- return;
-
- if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
- return;
-
- /*
- * To avoid all the problems that might happen if interrupts
- * were enabled/disabled around or between these calls, we just
- * have the kernel take a reference on the CRTC (just once though
- * to avoid corrupting the count if multiple, mismatch calls occur),
- * so that interrupts remain enabled in the interim.
- */
- if (!vblank->inmodeset) {
- vblank->inmodeset = 0x1;
- if (drm_vblank_get(dev, pipe) == 0)
- vblank->inmodeset |= 0x2;
- }
-}
-
-static void drm_legacy_vblank_post_modeset(struct drm_device *dev,
- unsigned int pipe)
-{
- struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
-
- /* vblank is not initialized (IRQ not installed ?), or has been freed */
- if (!drm_dev_has_vblank(dev))
- return;
-
- if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
- return;
-
- if (vblank->inmodeset) {
- spin_lock_irq(&dev->vbl_lock);
- drm_reset_vblank_timestamp(dev, pipe);
- spin_unlock_irq(&dev->vbl_lock);
-
- if (vblank->inmodeset & 0x2)
- drm_vblank_put(dev, pipe);
-
- vblank->inmodeset = 0;
- }
-}
-
-int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_modeset_ctl *modeset = data;
- unsigned int pipe;
-
- /* If drm_vblank_init() hasn't been called yet, just no-op */
- if (!drm_dev_has_vblank(dev))
- return 0;
-
- /* KMS drivers handle this internally */
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return 0;
-
- pipe = modeset->crtc;
- if (pipe >= dev->num_crtcs)
- return -EINVAL;
-
- switch (modeset->cmd) {
- case _DRM_PRE_MODESET:
- drm_legacy_vblank_pre_modeset(dev, pipe);
- break;
- case _DRM_POST_MODESET:
- drm_legacy_vblank_post_modeset(dev, pipe);
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
u64 req_seq,
union drm_wait_vblank *vblwait,
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 10/14] drm: Remove support for legacy drivers
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (8 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED Thomas Zimmermann
` (5 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
Remove all hooks and calls into code for user-space mode setting from
the DRM core. Without the drivers and ioctl entry points, none of this
is required any longer.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_auth.c | 8 +----
drivers/gpu/drm/drm_drv.c | 17 ----------
drivers/gpu/drm/drm_file.c | 64 ++----------------------------------
drivers/gpu/drm/drm_vblank.c | 19 -----------
4 files changed, 3 insertions(+), 105 deletions(-)
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 2ed2585ded378..252c105d614ff 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -37,13 +37,12 @@
#include <drm/drm_print.h>
#include "drm_internal.h"
-#include "drm_legacy.h"
/**
* DOC: master and authentication
*
* &struct drm_master is used to track groups of clients with open
- * primary/legacy device nodes. For every &struct drm_file which has had at
+ * primary device nodes. For every &struct drm_file which has had at
* least once successfully became the device master (either through the
* SET_MASTER IOCTL, or implicitly through opening the primary device node when
* no one else is the current master that time) there exists one &drm_master.
@@ -139,7 +138,6 @@ struct drm_master *drm_master_create(struct drm_device *dev)
return NULL;
kref_init(&master->refcount);
- drm_master_legacy_init(master);
idr_init_base(&master->magic_map, 1);
master->dev = dev;
@@ -365,8 +363,6 @@ void drm_master_release(struct drm_file *file_priv)
if (!drm_is_current_master_locked(file_priv))
goto out;
- drm_legacy_lock_master_cleanup(dev, master);
-
if (dev->master == file_priv->master)
drm_drop_master(dev, file_priv);
out:
@@ -429,8 +425,6 @@ static void drm_master_destroy(struct kref *kref)
if (drm_core_check_feature(dev, DRIVER_MODESET))
drm_lease_destroy(master);
- drm_legacy_master_rmmaps(dev, master);
-
idr_destroy(&master->magic_map);
idr_destroy(&master->leases);
idr_destroy(&master->lessee_idr);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 535f16e7882e7..979366e68dbb8 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -48,7 +48,6 @@
#include "drm_crtc_internal.h"
#include "drm_internal.h"
-#include "drm_legacy.h"
MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
MODULE_DESCRIPTION("DRM shared core routines");
@@ -585,8 +584,6 @@ static void drm_fs_inode_free(struct inode *inode)
static void drm_dev_init_release(struct drm_device *dev, void *res)
{
- drm_legacy_ctxbitmap_cleanup(dev);
- drm_legacy_remove_map_hash(dev);
drm_fs_inode_free(dev->anon_inode);
put_device(dev->dev);
@@ -597,7 +594,6 @@ static void drm_dev_init_release(struct drm_device *dev, void *res)
mutex_destroy(&dev->clientlist_mutex);
mutex_destroy(&dev->filelist_mutex);
mutex_destroy(&dev->struct_mutex);
- drm_legacy_destroy_members(dev);
}
static int drm_dev_init(struct drm_device *dev,
@@ -632,7 +628,6 @@ static int drm_dev_init(struct drm_device *dev,
return -EINVAL;
}
- drm_legacy_init_members(dev);
INIT_LIST_HEAD(&dev->filelist);
INIT_LIST_HEAD(&dev->filelist_internal);
INIT_LIST_HEAD(&dev->clientlist);
@@ -673,12 +668,6 @@ static int drm_dev_init(struct drm_device *dev,
goto err;
}
- ret = drm_legacy_create_map_hash(dev);
- if (ret)
- goto err;
-
- drm_legacy_ctxbitmap_init(dev);
-
if (drm_core_check_feature(dev, DRIVER_GEM)) {
ret = drm_gem_init(dev);
if (ret) {
@@ -990,9 +979,6 @@ EXPORT_SYMBOL(drm_dev_register);
*/
void drm_dev_unregister(struct drm_device *dev)
{
- if (drm_core_check_feature(dev, DRIVER_LEGACY))
- drm_lastclose(dev);
-
dev->registered = false;
drm_client_dev_unregister(dev);
@@ -1003,9 +989,6 @@ void drm_dev_unregister(struct drm_device *dev)
if (dev->driver->unload)
dev->driver->unload(dev);
- drm_legacy_pci_agp_destroy(dev);
- drm_legacy_rmmaps(dev);
-
remove_compat_control_link(dev);
drm_minor_unregister(dev, DRM_MINOR_ACCEL);
drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 5ddaffd325865..987c1a5d1773b 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -47,21 +47,12 @@
#include "drm_crtc_internal.h"
#include "drm_internal.h"
-#include "drm_legacy.h"
/* from BKL pushdown */
DEFINE_MUTEX(drm_global_mutex);
bool drm_dev_needs_global_mutex(struct drm_device *dev)
{
- /*
- * Legacy drivers rely on all kinds of BKL locking semantics, don't
- * bother. They also still need BKL locking for their ioctls, so better
- * safe than sorry.
- */
- if (drm_core_check_feature(dev, DRIVER_LEGACY))
- return true;
-
/*
* The deprecated ->load callback must be called after the driver is
* already registered. This means such drivers rely on the BKL to make
@@ -107,9 +98,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
* drm_send_event() as the main starting points.
*
* The memory mapping implementation will vary depending on how the driver
- * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
- * function, modern drivers should use one of the provided memory-manager
- * specific implementations. For GEM-based drivers this is drm_gem_mmap().
+ * manages memory. For GEM-based drivers this is drm_gem_mmap().
*
* No other file operations are supported by the DRM userspace API. Overall the
* following is an example &file_operations structure::
@@ -254,18 +243,6 @@ void drm_file_free(struct drm_file *file)
(long)old_encode_dev(file->minor->kdev->devt),
atomic_read(&dev->open_count));
-#ifdef CONFIG_DRM_LEGACY
- if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
- dev->driver->preclose)
- dev->driver->preclose(dev, file);
-#endif
-
- if (drm_core_check_feature(dev, DRIVER_LEGACY))
- drm_legacy_lock_release(dev, file->filp);
-
- if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- drm_legacy_reclaim_buffers(dev, file);
-
drm_events_release(file);
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
@@ -279,8 +256,6 @@ void drm_file_free(struct drm_file *file)
if (drm_core_check_feature(dev, DRIVER_GEM))
drm_gem_release(dev, file);
- drm_legacy_ctxbitmap_flush(dev, file);
-
if (drm_is_primary_client(file))
drm_master_release(file);
@@ -367,29 +342,6 @@ int drm_open_helper(struct file *filp, struct drm_minor *minor)
list_add(&priv->lhead, &dev->filelist);
mutex_unlock(&dev->filelist_mutex);
-#ifdef CONFIG_DRM_LEGACY
-#ifdef __alpha__
- /*
- * Default the hose
- */
- if (!dev->hose) {
- struct pci_dev *pci_dev;
-
- pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
- if (pci_dev) {
- dev->hose = pci_dev->sysdata;
- pci_dev_put(pci_dev);
- }
- if (!dev->hose) {
- struct pci_bus *b = list_entry(pci_root_buses.next,
- struct pci_bus, node);
- if (b)
- dev->hose = b->sysdata;
- }
- }
-#endif
-#endif
-
return 0;
}
@@ -411,7 +363,6 @@ int drm_open(struct inode *inode, struct file *filp)
struct drm_device *dev;
struct drm_minor *minor;
int retcode;
- int need_setup = 0;
minor = drm_minor_acquire(iminor(inode));
if (IS_ERR(minor))
@@ -421,8 +372,7 @@ int drm_open(struct inode *inode, struct file *filp)
if (drm_dev_needs_global_mutex(dev))
mutex_lock(&drm_global_mutex);
- if (!atomic_fetch_inc(&dev->open_count))
- need_setup = 1;
+ atomic_fetch_inc(&dev->open_count);
/* share address_space across all char-devs of a single device */
filp->f_mapping = dev->anon_inode->i_mapping;
@@ -430,13 +380,6 @@ int drm_open(struct inode *inode, struct file *filp)
retcode = drm_open_helper(filp, minor);
if (retcode)
goto err_undo;
- if (need_setup) {
- retcode = drm_legacy_setup(dev);
- if (retcode) {
- drm_close_helper(filp);
- goto err_undo;
- }
- }
if (drm_dev_needs_global_mutex(dev))
mutex_unlock(&drm_global_mutex);
@@ -460,9 +403,6 @@ void drm_lastclose(struct drm_device * dev)
dev->driver->lastclose(dev);
drm_dbg_core(dev, "driver lastclose completed\n");
- if (drm_core_check_feature(dev, DRIVER_LEGACY))
- drm_legacy_dev_reinit(dev);
-
drm_client_dev_restore(dev);
}
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index a11f164b2384f..702a12bc93bd9 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -210,11 +210,6 @@ static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
if (crtc->funcs->get_vblank_counter)
return crtc->funcs->get_vblank_counter(crtc);
}
-#ifdef CONFIG_DRM_LEGACY
- else if (dev->driver->get_vblank_counter) {
- return dev->driver->get_vblank_counter(dev, pipe);
- }
-#endif
return drm_vblank_no_hw_counter(dev, pipe);
}
@@ -433,11 +428,6 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
if (crtc->funcs->disable_vblank)
crtc->funcs->disable_vblank(crtc);
}
-#ifdef CONFIG_DRM_LEGACY
- else {
- dev->driver->disable_vblank(dev, pipe);
- }
-#endif
}
/*
@@ -1151,11 +1141,6 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
if (crtc->funcs->enable_vblank)
return crtc->funcs->enable_vblank(crtc);
}
-#ifdef CONFIG_DRM_LEGACY
- else if (dev->driver->enable_vblank) {
- return dev->driver->enable_vblank(dev, pipe);
- }
-#endif
return -EINVAL;
}
@@ -1698,10 +1683,6 @@ static void drm_wait_vblank_reply(struct drm_device *dev, unsigned int pipe,
static bool drm_wait_vblank_supported(struct drm_device *dev)
{
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- if (unlikely(drm_core_check_feature(dev, DRIVER_LEGACY)))
- return dev->irq_enabled;
-#endif
return drm_dev_has_vblank(dev);
}
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (9 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 10/14] drm: Remove support for legacy drivers Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 12/14] drm: Remove source code for non-KMS drivers Thomas Zimmermann
` (4 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
Modern DRM drivers acquire ioctl locks by themselves. Legacy ioctls
for user-space mode setting used to acquire drm_global_mutex. After
removing the ioctl entry points, also remove the locking code. The only
legacy ioctl without global locking was VBLANK_WAIT, which has been
removed as well. Hence remove the related DRM_UNLOCKED flag.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_ioc32.c | 2 +-
drivers/gpu/drm/drm_ioctl.c | 23 +++++++----------------
include/drm/drm_ioctl.h | 11 -----------
3 files changed, 8 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 910cadf14756e..129e2b91dbfe7 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -273,7 +273,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
req.request.type = req32.request.type;
req.request.sequence = req32.request.sequence;
req.request.signal = req32.request.signal;
- err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED);
+ err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, 0);
req32.reply.type = req.reply.type;
req32.reply.sequence = req.reply.sequence;
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9c6326b908e74..1cf1de342d6aa 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -583,7 +583,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, 0),
DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
@@ -716,7 +716,7 @@ long drm_ioctl_kernel(struct file *file, drm_ioctl_t *func, void *kdata,
{
struct drm_file *file_priv = file->private_data;
struct drm_device *dev = file_priv->minor->dev;
- int retcode;
+ int ret;
/* Update drm_file owner if fd was passed along. */
drm_file_update_pid(file_priv);
@@ -724,20 +724,11 @@ long drm_ioctl_kernel(struct file *file, drm_ioctl_t *func, void *kdata,
if (drm_dev_is_unplugged(dev))
return -ENODEV;
- retcode = drm_ioctl_permit(flags, file_priv);
- if (unlikely(retcode))
- return retcode;
-
- /* Enforce sane locking for modern driver ioctls. */
- if (likely(!drm_core_check_feature(dev, DRIVER_LEGACY)) ||
- (flags & DRM_UNLOCKED))
- retcode = func(dev, kdata, file_priv);
- else {
- mutex_lock(&drm_global_mutex);
- retcode = func(dev, kdata, file_priv);
- mutex_unlock(&drm_global_mutex);
- }
- return retcode;
+ ret = drm_ioctl_permit(flags, file_priv);
+ if (unlikely(ret))
+ return ret;
+
+ return func(dev, kdata, file_priv);
}
EXPORT_SYMBOL(drm_ioctl_kernel);
diff --git a/include/drm/drm_ioctl.h b/include/drm/drm_ioctl.h
index 6ed61c371f6ce..171760b6c4a14 100644
--- a/include/drm/drm_ioctl.h
+++ b/include/drm/drm_ioctl.h
@@ -109,17 +109,6 @@ enum drm_ioctl_flags {
* This is equivalent to callers with the SYSADMIN capability.
*/
DRM_ROOT_ONLY = BIT(2),
- /**
- * @DRM_UNLOCKED:
- *
- * Whether &drm_ioctl_desc.func should be called with the DRM BKL held
- * or not. Enforced as the default for all modern drivers, hence there
- * should never be a need to set this flag.
- *
- * Do not use anywhere else than for the VBLANK_WAIT IOCTL, which is the
- * only legacy IOCTL which needs this.
- */
- DRM_UNLOCKED = BIT(4),
/**
* @DRM_RENDER_ALLOW:
*
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 12/14] drm: Remove source code for non-KMS drivers
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (10 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:06 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 13/14] char/agp: Remove frontend code Thomas Zimmermann
` (3 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
Remove all remaining source code for non-KMS drivers. These drivers
have been removed in v6.3 and won't comeback.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/Makefile | 12 -
drivers/gpu/drm/drm_agpsupport.c | 451 --------
drivers/gpu/drm/drm_bufs.c | 1627 -----------------------------
drivers/gpu/drm/drm_context.c | 513 ---------
drivers/gpu/drm/drm_dma.c | 178 ----
drivers/gpu/drm/drm_hashtab.c | 203 ----
drivers/gpu/drm/drm_internal.h | 5 -
drivers/gpu/drm/drm_irq.c | 204 ----
drivers/gpu/drm/drm_legacy.h | 290 -----
drivers/gpu/drm/drm_legacy_misc.c | 105 --
drivers/gpu/drm/drm_lock.c | 373 -------
drivers/gpu/drm/drm_memory.c | 138 ---
drivers/gpu/drm/drm_pci.c | 203 ----
drivers/gpu/drm/drm_scatter.c | 220 ----
drivers/gpu/drm/drm_vm.c | 665 ------------
include/drm/drm_auth.h | 22 -
include/drm/drm_device.h | 71 +-
include/drm/drm_drv.h | 19 -
include/drm/drm_file.h | 5 -
include/drm/drm_legacy.h | 331 ------
20 files changed, 2 insertions(+), 5633 deletions(-)
delete mode 100644 drivers/gpu/drm/drm_agpsupport.c
delete mode 100644 drivers/gpu/drm/drm_bufs.c
delete mode 100644 drivers/gpu/drm/drm_context.c
delete mode 100644 drivers/gpu/drm/drm_dma.c
delete mode 100644 drivers/gpu/drm/drm_hashtab.c
delete mode 100644 drivers/gpu/drm/drm_irq.c
delete mode 100644 drivers/gpu/drm/drm_legacy.h
delete mode 100644 drivers/gpu/drm/drm_legacy_misc.c
delete mode 100644 drivers/gpu/drm/drm_lock.c
delete mode 100644 drivers/gpu/drm/drm_memory.c
delete mode 100644 drivers/gpu/drm/drm_scatter.c
delete mode 100644 drivers/gpu/drm/drm_vm.c
delete mode 100644 include/drm/drm_legacy.h
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index cdbe91ac0bfc8..1b5f3d8bd443f 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -47,18 +47,6 @@ drm-y := \
drm_vblank_work.o \
drm_vma_manager.o \
drm_writeback.o
-drm-$(CONFIG_DRM_LEGACY) += \
- drm_agpsupport.o \
- drm_bufs.o \
- drm_context.o \
- drm_dma.o \
- drm_hashtab.o \
- drm_irq.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_PANEL) += drm_panel.o
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
deleted file mode 100644
index a4ad6fd13abcf..0000000000000
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * \file drm_agpsupport.c
- * DRM support for AGP/GART backend
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-
-#if IS_ENABLED(CONFIG_AGP)
-#include <asm/agp.h>
-#endif
-
-#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.
- *
- * \return zero on success or a negative number on failure.
- *
- * 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_legacy_agp_info(struct drm_device *dev, struct drm_agp_info *info)
-{
- struct agp_kern_info *kern;
-
- if (!dev->agp || !dev->agp->acquired)
- return -EINVAL;
-
- kern = &dev->agp->agp_info;
- info->agp_version_major = kern->version.major;
- info->agp_version_minor = kern->version.minor;
- info->mode = kern->mode;
- info->aperture_base = kern->aper_base;
- info->aperture_size = kern->aper_size * 1024 * 1024;
- info->memory_allowed = kern->max_memory << PAGE_SHIFT;
- info->memory_used = kern->current_memory << PAGE_SHIFT;
- info->id_vendor = kern->device->vendor;
- info->id_device = kern->device->device;
-
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_agp_info);
-
-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_legacy_agp_info(dev, info);
- if (err)
- return err;
-
- return 0;
-}
-
-/*
- * Acquire the AGP device.
- *
- * \param dev DRM device that is to acquire AGP.
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device hasn't been acquired before and calls
- * \c agp_backend_acquire.
- */
-int drm_legacy_agp_acquire(struct drm_device *dev)
-{
- struct pci_dev *pdev = to_pci_dev(dev->dev);
-
- if (!dev->agp)
- return -ENODEV;
- if (dev->agp->acquired)
- return -EBUSY;
- dev->agp->bridge = agp_backend_acquire(pdev);
- if (!dev->agp->bridge)
- return -ENODEV;
- dev->agp->acquired = 1;
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_agp_acquire);
-
-/*
- * Acquire the AGP device (ioctl).
- *
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device hasn't been acquired before and calls
- * \c agp_backend_acquire.
- */
-int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- return drm_legacy_agp_acquire((struct drm_device *)file_priv->minor->dev);
-}
-
-/*
- * Release the AGP device.
- *
- * \param dev DRM device that is to release AGP.
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device has been acquired and calls \c agp_backend_release.
- */
-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_legacy_agp_release);
-
-int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- return drm_legacy_agp_release(dev);
-}
-
-/*
- * Enable the AGP bus.
- *
- * \param dev DRM device that has previously acquired AGP.
- * \param mode Requested AGP mode.
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device has been acquired but not enabled, and calls
- * \c agp_enable.
- */
-int drm_legacy_agp_enable(struct drm_device *dev, struct drm_agp_mode mode)
-{
- if (!dev->agp || !dev->agp->acquired)
- return -EINVAL;
-
- dev->agp->mode = mode.mode;
- agp_enable(dev->agp->bridge, mode.mode);
- dev->agp->enabled = 1;
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_agp_enable);
-
-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_legacy_agp_enable(dev, *mode);
-}
-
-/*
- * Allocate AGP memory.
- *
- * \return zero on success or a negative number on failure.
- *
- * 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_legacy_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
-{
- struct drm_agp_mem *entry;
- struct agp_memory *memory;
- unsigned long pages;
- u32 type;
-
- if (!dev->agp || !dev->agp->acquired)
- return -EINVAL;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
- if (!entry)
- return -ENOMEM;
-
- pages = DIV_ROUND_UP(request->size, PAGE_SIZE);
- type = (u32) request->type;
- memory = agp_allocate_memory(dev->agp->bridge, pages, type);
- if (!memory) {
- kfree(entry);
- return -ENOMEM;
- }
-
- entry->handle = (unsigned long)memory->key + 1;
- entry->memory = memory;
- entry->bound = 0;
- entry->pages = pages;
- list_add(&entry->head, &dev->agp->memory);
-
- request->handle = entry->handle;
- request->physical = memory->physical;
-
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_agp_alloc);
-
-
-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_legacy_agp_alloc(dev, request);
-}
-
-/*
- * Search for the AGP memory entry associated with a handle.
- *
- * \param dev DRM device structure.
- * \param handle AGP memory handle.
- * \return pointer to the drm_agp_mem structure associated with \p handle.
- *
- * Walks through drm_agp_head::memory until finding a matching handle.
- */
-static struct drm_agp_mem *drm_legacy_agp_lookup_entry(struct drm_device *dev,
- unsigned long handle)
-{
- struct drm_agp_mem *entry;
-
- list_for_each_entry(entry, &dev->agp->memory, head) {
- if (entry->handle == handle)
- return entry;
- }
- return NULL;
-}
-
-/*
- * Unbind AGP memory from the GATT (ioctl).
- *
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device is present and acquired, looks-up the AGP memory
- * entry and passes it to the unbind_agp() function.
- */
-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_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_legacy_agp_unbind);
-
-
-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_legacy_agp_unbind(dev, request);
-}
-
-/*
- * Bind AGP memory into the GATT (ioctl)
- *
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device is present and has been acquired and that no memory
- * is currently bound into the GATT. Looks-up the AGP memory entry and passes
- * it to bind_agp() function.
- */
-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_legacy_agp_lookup_entry(dev, request->handle);
- if (!entry || entry->bound)
- return -EINVAL;
- page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
- retcode = agp_bind_memory(entry->memory, page);
- if (retcode)
- return retcode;
- entry->bound = dev->agp->base + (page << PAGE_SHIFT);
- DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
- dev->agp->base, entry->bound);
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_agp_bind);
-
-
-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_legacy_agp_bind(dev, request);
-}
-
-/*
- * Free AGP memory (ioctl).
- *
- * \return zero on success or a negative number on failure.
- *
- * Verifies the AGP device is present and has been acquired and looks up the
- * AGP memory entry. If the memory is currently bound, unbind it via
- * 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_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_legacy_agp_lookup_entry(dev, request->handle);
- if (!entry)
- return -EINVAL;
- if (entry->bound)
- agp_unbind_memory(entry->memory);
-
- list_del(&entry->head);
-
- agp_free_memory(entry->memory);
- kfree(entry);
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_agp_free);
-
-
-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_legacy_agp_free(dev, request);
-}
-
-/*
- * Initialize the AGP resources.
- *
- * \return pointer to a drm_agp_head structure.
- *
- * Gets the drm_agp_t structure which is made available by the agpgart module
- * via the inter_module_* functions. Creates and initializes a drm_agp_head
- * structure.
- *
- * Note that final cleanup of the kmalloced structure is directly done in
- * drm_pci_agp_destroy.
- */
-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;
-
- head = kzalloc(sizeof(*head), GFP_KERNEL);
- if (!head)
- return NULL;
- head->bridge = agp_find_bridge(pdev);
- if (!head->bridge) {
- head->bridge = agp_backend_acquire(pdev);
- if (!head->bridge) {
- kfree(head);
- return NULL;
- }
- agp_copy_info(head->bridge, &head->agp_info);
- agp_backend_release(head->bridge);
- } else {
- agp_copy_info(head->bridge, &head->agp_info);
- }
- if (head->agp_info.chipset == NOT_SUPPORTED) {
- kfree(head);
- return NULL;
- }
- INIT_LIST_HEAD(&head->memory);
- head->cant_use_aperture = head->agp_info.cant_use_aperture;
- head->page_mask = head->agp_info.page_mask;
- head->base = head->agp_info.aper_base;
- return head;
-}
-/* Only exported for i810.ko */
-EXPORT_SYMBOL(drm_legacy_agp_init);
-
-/**
- * drm_legacy_agp_clear - Clear AGP resource list
- * @dev: DRM device
- *
- * Iterate over all AGP resources and remove them. But keep the AGP head
- * intact so it can still be used. It is safe to call this if AGP is disabled or
- * was already removed.
- *
- * Cleanup is only done for drivers who have DRIVER_LEGACY set.
- */
-void drm_legacy_agp_clear(struct drm_device *dev)
-{
- struct drm_agp_mem *entry, *tempe;
-
- if (!dev->agp)
- return;
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
- if (entry->bound)
- agp_unbind_memory(entry->memory);
- agp_free_memory(entry->memory);
- kfree(entry);
- }
- INIT_LIST_HEAD(&dev->agp->memory);
-
- if (dev->agp->acquired)
- drm_legacy_agp_release(dev);
-
- dev->agp->acquired = 0;
- dev->agp->enabled = 0;
-}
-
-#endif
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
deleted file mode 100644
index 86700560fea28..0000000000000
--- a/drivers/gpu/drm/drm_bufs.c
+++ /dev/null
@@ -1,1627 +0,0 @@
-/*
- * Legacy: Generic DRM Buffer Management
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Author: Rickard E. (Rik) Faith <faith@valinux.com>
- * Author: Gareth Hughes <gareth@valinux.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/export.h>
-#include <linux/log2.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
-#include <linux/nospec.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/vmalloc.h>
-
-#include <asm/shmparam.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"
-
-
-static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
- struct drm_local_map *map)
-{
- struct drm_map_list *entry;
-
- list_for_each_entry(entry, &dev->maplist, head) {
- /*
- * Because the kernel-userspace ABI is fixed at a 32-bit offset
- * while PCI resources may live above that, we only compare the
- * lower 32 bits of the map offset for maps of type
- * _DRM_FRAMEBUFFER or _DRM_REGISTERS.
- * It is assumed that if a driver have more than one resource
- * of each type, the lower 32 bits are different.
- */
- if (!entry->map ||
- map->type != entry->map->type ||
- entry->master != dev->master)
- continue;
- switch (map->type) {
- case _DRM_SHM:
- if (map->flags != _DRM_CONTAINS_LOCK)
- break;
- return entry;
- case _DRM_REGISTERS:
- case _DRM_FRAME_BUFFER:
- if ((entry->map->offset & 0xffffffff) ==
- (map->offset & 0xffffffff))
- return entry;
- break;
- default: /* Make gcc happy */
- break;
- }
- if (entry->map->offset == map->offset)
- return entry;
- }
-
- return NULL;
-}
-
-static int drm_map_handle(struct drm_device *dev, struct drm_hash_item *hash,
- unsigned long user_token, int hashed_handle, int shm)
-{
- int use_hashed_handle, shift;
- unsigned long add;
-
-#if (BITS_PER_LONG == 64)
- use_hashed_handle = ((user_token & 0xFFFFFFFF00000000UL) || hashed_handle);
-#elif (BITS_PER_LONG == 32)
- use_hashed_handle = hashed_handle;
-#else
-#error Unsupported long size. Neither 64 nor 32 bits.
-#endif
-
- if (!use_hashed_handle) {
- int ret;
-
- hash->key = user_token >> PAGE_SHIFT;
- ret = drm_ht_insert_item(&dev->map_hash, hash);
- if (ret != -EINVAL)
- return ret;
- }
-
- shift = 0;
- add = DRM_MAP_HASH_OFFSET >> PAGE_SHIFT;
- if (shm && (SHMLBA > PAGE_SIZE)) {
- int bits = ilog2(SHMLBA >> PAGE_SHIFT) + 1;
-
- /* For shared memory, we have to preserve the SHMLBA
- * bits of the eventual vma->vm_pgoff value during
- * mmap(). Otherwise we run into cache aliasing problems
- * on some platforms. On these platforms, the pgoff of
- * a mmap() request is used to pick a suitable virtual
- * address for the mmap() region such that it will not
- * cause cache aliasing problems.
- *
- * Therefore, make sure the SHMLBA relevant bits of the
- * hash value we use are equal to those in the original
- * kernel virtual address.
- */
- shift = bits;
- add |= ((user_token >> PAGE_SHIFT) & ((1UL << bits) - 1UL));
- }
-
- return drm_ht_just_insert_please(&dev->map_hash, hash,
- user_token, 32 - PAGE_SHIFT - 3,
- shift, add);
-}
-
-/*
- * Core function to create a range of memory available for mapping by a
- * non-root process.
- *
- * Adjusts the memory offset to its absolute value according to the mapping
- * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where
- * applicable and if supported by the kernel.
- */
-static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
- unsigned int size, enum drm_map_type type,
- enum drm_map_flags flags,
- struct drm_map_list **maplist)
-{
- struct drm_local_map *map;
- struct drm_map_list *list;
- unsigned long user_token;
- int ret;
-
- map = kmalloc(sizeof(*map), GFP_KERNEL);
- if (!map)
- return -ENOMEM;
-
- map->offset = offset;
- map->size = size;
- map->flags = flags;
- map->type = type;
-
- /* Only allow shared memory to be removable since we only keep enough
- * book keeping information about shared memory to allow for removal
- * when processes fork.
- */
- if ((map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM) {
- kfree(map);
- return -EINVAL;
- }
- DRM_DEBUG("offset = 0x%08llx, size = 0x%08lx, type = %d\n",
- (unsigned long long)map->offset, map->size, map->type);
-
- /* page-align _DRM_SHM maps. They are allocated here so there is no security
- * hole created by that and it works around various broken drivers that use
- * a non-aligned quantity to map the SAREA. --BenH
- */
- if (map->type == _DRM_SHM)
- map->size = PAGE_ALIGN(map->size);
-
- if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) {
- kfree(map);
- return -EINVAL;
- }
- map->mtrr = -1;
- map->handle = NULL;
-
- switch (map->type) {
- case _DRM_REGISTERS:
- case _DRM_FRAME_BUFFER:
-#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
- if (map->offset + (map->size-1) < map->offset ||
- map->offset < virt_to_phys(high_memory)) {
- kfree(map);
- return -EINVAL;
- }
-#endif
- /* Some drivers preinitialize some maps, without the X Server
- * needing to be aware of it. Therefore, we just return success
- * when the server tries to create a duplicate map.
- */
- list = drm_find_matching_map(dev, map);
- if (list != NULL) {
- if (list->map->size != map->size) {
- DRM_DEBUG("Matching maps of type %d with "
- "mismatched sizes, (%ld vs %ld)\n",
- map->type, map->size,
- list->map->size);
- list->map->size = map->size;
- }
-
- kfree(map);
- *maplist = list;
- return 0;
- }
-
- if (map->type == _DRM_FRAME_BUFFER ||
- (map->flags & _DRM_WRITE_COMBINING)) {
- map->mtrr =
- arch_phys_wc_add(map->offset, map->size);
- }
- if (map->type == _DRM_REGISTERS) {
- if (map->flags & _DRM_WRITE_COMBINING)
- map->handle = ioremap_wc(map->offset,
- map->size);
- else
- map->handle = ioremap(map->offset, map->size);
- if (!map->handle) {
- kfree(map);
- return -ENOMEM;
- }
- }
-
- break;
- case _DRM_SHM:
- list = drm_find_matching_map(dev, map);
- if (list != NULL) {
- if (list->map->size != map->size) {
- DRM_DEBUG("Matching maps of type %d with "
- "mismatched sizes, (%ld vs %ld)\n",
- map->type, map->size, list->map->size);
- list->map->size = map->size;
- }
-
- kfree(map);
- *maplist = list;
- return 0;
- }
- map->handle = vmalloc_user(map->size);
- DRM_DEBUG("%lu %d %p\n",
- map->size, order_base_2(map->size), map->handle);
- if (!map->handle) {
- kfree(map);
- return -ENOMEM;
- }
- map->offset = (unsigned long)map->handle;
- if (map->flags & _DRM_CONTAINS_LOCK) {
- /* Prevent a 2nd X Server from creating a 2nd lock */
- if (dev->master->lock.hw_lock != NULL) {
- vfree(map->handle);
- kfree(map);
- return -EBUSY;
- }
- dev->sigdata.lock = dev->master->lock.hw_lock = map->handle; /* Pointer to lock */
- }
- break;
- case _DRM_AGP: {
- struct drm_agp_mem *entry;
- int valid = 0;
-
- if (!dev->agp) {
- kfree(map);
- return -EINVAL;
- }
-#ifdef __alpha__
- map->offset += dev->hose->mem_space->start;
-#endif
- /* In some cases (i810 driver), user space may have already
- * added the AGP base itself, because dev->agp->base previously
- * only got set during AGP enable. So, only add the base
- * address if the map's offset isn't already within the
- * aperture.
- */
- if (map->offset < dev->agp->base ||
- map->offset > dev->agp->base +
- dev->agp->agp_info.aper_size * 1024 * 1024 - 1) {
- map->offset += dev->agp->base;
- }
- map->mtrr = dev->agp->agp_mtrr; /* for getmap */
-
- /* This assumes the DRM is in total control of AGP space.
- * It's not always the case as AGP can be in the control
- * of user space (i.e. i810 driver). So this loop will get
- * skipped and we double check that dev->agp->memory is
- * actually set as well as being invalid before EPERM'ing
- */
- list_for_each_entry(entry, &dev->agp->memory, head) {
- if ((map->offset >= entry->bound) &&
- (map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) {
- valid = 1;
- break;
- }
- }
- if (!list_empty(&dev->agp->memory) && !valid) {
- kfree(map);
- return -EPERM;
- }
- DRM_DEBUG("AGP offset = 0x%08llx, size = 0x%08lx\n",
- (unsigned long long)map->offset, map->size);
-
- break;
- }
- case _DRM_SCATTER_GATHER:
- if (!dev->sg) {
- kfree(map);
- return -EINVAL;
- }
- map->offset += (unsigned long)dev->sg->virtual;
- break;
- case _DRM_CONSISTENT:
- /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G,
- * As we're limiting the address to 2^32-1 (or less),
- * casting it down to 32 bits is no problem, but we
- * need to point to a 64bit variable first.
- */
- map->handle = dma_alloc_coherent(dev->dev,
- map->size,
- &map->offset,
- GFP_KERNEL);
- if (!map->handle) {
- kfree(map);
- return -ENOMEM;
- }
- break;
- default:
- kfree(map);
- return -EINVAL;
- }
-
- list = kzalloc(sizeof(*list), GFP_KERNEL);
- if (!list) {
- if (map->type == _DRM_REGISTERS)
- iounmap(map->handle);
- kfree(map);
- return -EINVAL;
- }
- list->map = map;
-
- mutex_lock(&dev->struct_mutex);
- list_add(&list->head, &dev->maplist);
-
- /* Assign a 32-bit handle */
- /* We do it here so that dev->struct_mutex protects the increment */
- user_token = (map->type == _DRM_SHM) ? (unsigned long)map->handle :
- map->offset;
- ret = drm_map_handle(dev, &list->hash, user_token, 0,
- (map->type == _DRM_SHM));
- if (ret) {
- if (map->type == _DRM_REGISTERS)
- iounmap(map->handle);
- kfree(map);
- kfree(list);
- mutex_unlock(&dev->struct_mutex);
- return ret;
- }
-
- list->user_token = list->hash.key << PAGE_SHIFT;
- mutex_unlock(&dev->struct_mutex);
-
- if (!(map->flags & _DRM_DRIVER))
- list->master = dev->master;
- *maplist = list;
- return 0;
-}
-
-int drm_legacy_addmap(struct drm_device *dev, resource_size_t offset,
- unsigned int size, enum drm_map_type type,
- enum drm_map_flags flags, struct drm_local_map **map_ptr)
-{
- struct drm_map_list *list;
- int rc;
-
- rc = drm_addmap_core(dev, offset, size, type, flags, &list);
- if (!rc)
- *map_ptr = list->map;
- return rc;
-}
-EXPORT_SYMBOL(drm_legacy_addmap);
-
-struct drm_local_map *drm_legacy_findmap(struct drm_device *dev,
- unsigned int token)
-{
- struct drm_map_list *_entry;
-
- list_for_each_entry(_entry, &dev->maplist, head)
- if (_entry->user_token == token)
- return _entry->map;
- return NULL;
-}
-EXPORT_SYMBOL(drm_legacy_findmap);
-
-/*
- * Ioctl to specify a range of memory that is available for mapping by a
- * non-root process.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg pointer to a drm_map structure.
- * \return zero on success or a negative value on error.
- *
- */
-int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_map *map = data;
- struct drm_map_list *maplist;
- int err;
-
- if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM))
- return -EPERM;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- err = drm_addmap_core(dev, map->offset, map->size, map->type,
- map->flags, &maplist);
-
- if (err)
- return err;
-
- /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */
- map->handle = (void *)(unsigned long)maplist->user_token;
-
- /*
- * It appears that there are no users of this value whatsoever --
- * drmAddMap just discards it. Let's not encourage its use.
- * (Keeping drm_addmap_core's returned mtrr value would be wrong --
- * it's not a real mtrr index anymore.)
- */
- map->mtrr = -1;
-
- return 0;
-}
-
-/*
- * Get a mapping information.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument, pointing to a drm_map structure.
- *
- * \return zero on success or a negative number on failure.
- *
- * Searches for the mapping with the specified offset and copies its information
- * into userspace
- */
-int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_map *map = data;
- struct drm_map_list *r_list = NULL;
- struct list_head *list;
- int idx;
- int i;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- idx = map->offset;
- if (idx < 0)
- return -EINVAL;
-
- i = 0;
- mutex_lock(&dev->struct_mutex);
- list_for_each(list, &dev->maplist) {
- if (i == idx) {
- r_list = list_entry(list, struct drm_map_list, head);
- break;
- }
- i++;
- }
- if (!r_list || !r_list->map) {
- mutex_unlock(&dev->struct_mutex);
- return -EINVAL;
- }
-
- map->offset = r_list->map->offset;
- map->size = r_list->map->size;
- map->type = r_list->map->type;
- map->flags = r_list->map->flags;
- map->handle = (void *)(unsigned long) r_list->user_token;
- map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
-
- mutex_unlock(&dev->struct_mutex);
-
- return 0;
-}
-
-/*
- * Remove a map private from list and deallocate resources if the mapping
- * isn't in use.
- *
- * Searches the map on drm_device::maplist, removes it from the list, see if
- * it's being used, and free any associated resource (such as MTRR's) if it's not
- * being on use.
- *
- * \sa drm_legacy_addmap
- */
-int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
-{
- struct drm_map_list *r_list = NULL, *list_t;
- int found = 0;
- struct drm_master *master;
-
- /* Find the list entry for the map and remove it */
- list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
- if (r_list->map == map) {
- master = r_list->master;
- list_del(&r_list->head);
- drm_ht_remove_key(&dev->map_hash,
- r_list->user_token >> PAGE_SHIFT);
- kfree(r_list);
- found = 1;
- break;
- }
- }
-
- if (!found)
- return -EINVAL;
-
- switch (map->type) {
- case _DRM_REGISTERS:
- iounmap(map->handle);
- fallthrough;
- case _DRM_FRAME_BUFFER:
- arch_phys_wc_del(map->mtrr);
- break;
- case _DRM_SHM:
- vfree(map->handle);
- if (master) {
- if (dev->sigdata.lock == master->lock.hw_lock)
- dev->sigdata.lock = NULL;
- master->lock.hw_lock = NULL; /* SHM removed */
- master->lock.file_priv = NULL;
- wake_up_interruptible_all(&master->lock.lock_queue);
- }
- break;
- case _DRM_AGP:
- case _DRM_SCATTER_GATHER:
- break;
- case _DRM_CONSISTENT:
- dma_free_coherent(dev->dev,
- map->size,
- map->handle,
- map->offset);
- break;
- }
- kfree(map);
-
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_rmmap_locked);
-
-void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
-{
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- mutex_lock(&dev->struct_mutex);
- drm_legacy_rmmap_locked(dev, map);
- mutex_unlock(&dev->struct_mutex);
-}
-EXPORT_SYMBOL(drm_legacy_rmmap);
-
-void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
-{
- struct drm_map_list *r_list, *list_temp;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- mutex_lock(&dev->struct_mutex);
- list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
- if (r_list->master == master) {
- drm_legacy_rmmap_locked(dev, r_list->map);
- r_list = NULL;
- }
- }
- mutex_unlock(&dev->struct_mutex);
-}
-
-void drm_legacy_rmmaps(struct drm_device *dev)
-{
- struct drm_map_list *r_list, *list_temp;
-
- list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
- drm_legacy_rmmap(dev, r_list->map);
-}
-
-/* The rmmap ioctl appears to be unnecessary. All mappings are torn down on
- * the last close of the device, and this is necessary for cleanup when things
- * exit uncleanly. Therefore, having userland manually remove mappings seems
- * like a pointless exercise since they're going away anyway.
- *
- * One use case might be after addmap is allowed for normal users for SHM and
- * gets used by drivers that the server doesn't need to care about. This seems
- * unlikely.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg pointer to a struct drm_map structure.
- * \return zero on success or a negative value on error.
- */
-int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_map *request = data;
- struct drm_local_map *map = NULL;
- struct drm_map_list *r_list;
- int ret;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- mutex_lock(&dev->struct_mutex);
- list_for_each_entry(r_list, &dev->maplist, head) {
- if (r_list->map &&
- r_list->user_token == (unsigned long)request->handle &&
- r_list->map->flags & _DRM_REMOVABLE) {
- map = r_list->map;
- break;
- }
- }
-
- /* List has wrapped around to the head pointer, or it's empty we didn't
- * find anything.
- */
- if (list_empty(&dev->maplist) || !map) {
- mutex_unlock(&dev->struct_mutex);
- return -EINVAL;
- }
-
- /* Register and framebuffer maps are permanent */
- if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) {
- mutex_unlock(&dev->struct_mutex);
- return 0;
- }
-
- ret = drm_legacy_rmmap_locked(dev, map);
-
- mutex_unlock(&dev->struct_mutex);
-
- return ret;
-}
-
-/*
- * Cleanup after an error on one of the addbufs() functions.
- *
- * \param dev DRM device.
- * \param entry buffer entry where the error occurred.
- *
- * Frees any pages and buffers associated with the given entry.
- */
-static void drm_cleanup_buf_error(struct drm_device *dev,
- struct drm_buf_entry *entry)
-{
- drm_dma_handle_t *dmah;
- int i;
-
- if (entry->seg_count) {
- for (i = 0; i < entry->seg_count; i++) {
- if (entry->seglist[i]) {
- dmah = entry->seglist[i];
- dma_free_coherent(dev->dev,
- dmah->size,
- dmah->vaddr,
- dmah->busaddr);
- kfree(dmah);
- }
- }
- kfree(entry->seglist);
-
- entry->seg_count = 0;
- }
-
- if (entry->buf_count) {
- for (i = 0; i < entry->buf_count; i++) {
- kfree(entry->buflist[i].dev_private);
- }
- kfree(entry->buflist);
-
- entry->buf_count = 0;
- }
-}
-
-#if IS_ENABLED(CONFIG_AGP)
-/*
- * Add AGP buffers for DMA transfers.
- *
- * \param dev struct drm_device to which the buffers are to be added.
- * \param request pointer to a struct drm_buf_desc describing the request.
- * \return zero on success or a negative number on failure.
- *
- * After some sanity checks creates a drm_buf structure for each buffer and
- * reallocates the buffer list of the same size order to accommodate the new
- * buffers.
- */
-int drm_legacy_addbufs_agp(struct drm_device *dev,
- struct drm_buf_desc *request)
-{
- struct drm_device_dma *dma = dev->dma;
- struct drm_buf_entry *entry;
- struct drm_agp_mem *agp_entry;
- struct drm_buf *buf;
- unsigned long offset;
- unsigned long agp_offset;
- int count;
- int order;
- int size;
- int alignment;
- int page_order;
- int total;
- int byte_count;
- int i, valid;
- struct drm_buf **temp_buflist;
-
- if (!dma)
- return -EINVAL;
-
- count = request->count;
- order = order_base_2(request->size);
- size = 1 << order;
-
- alignment = (request->flags & _DRM_PAGE_ALIGN)
- ? PAGE_ALIGN(size) : size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
- byte_count = 0;
- agp_offset = dev->agp->base + request->agp_start;
-
- DRM_DEBUG("count: %d\n", count);
- DRM_DEBUG("order: %d\n", order);
- DRM_DEBUG("size: %d\n", size);
- DRM_DEBUG("agp_offset: %lx\n", agp_offset);
- DRM_DEBUG("alignment: %d\n", alignment);
- DRM_DEBUG("page_order: %d\n", page_order);
- DRM_DEBUG("total: %d\n", total);
-
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return -EINVAL;
-
- /* Make sure buffers are located in AGP memory that we own */
- valid = 0;
- list_for_each_entry(agp_entry, &dev->agp->memory, head) {
- if ((agp_offset >= agp_entry->bound) &&
- (agp_offset + total * count <= agp_entry->bound + agp_entry->pages * PAGE_SIZE)) {
- valid = 1;
- break;
- }
- }
- if (!list_empty(&dev->agp->memory) && !valid) {
- DRM_DEBUG("zone invalid\n");
- return -EINVAL;
- }
- spin_lock(&dev->buf_lock);
- if (dev->buf_use) {
- spin_unlock(&dev->buf_lock);
- return -EBUSY;
- }
- atomic_inc(&dev->buf_alloc);
- spin_unlock(&dev->buf_lock);
-
- mutex_lock(&dev->struct_mutex);
- entry = &dma->bufs[order];
- if (entry->buf_count) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM; /* May only call once for each order */
- }
-
- if (count < 0 || count > 4096) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -EINVAL;
- }
-
- entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
- if (!entry->buflist) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- entry->buf_size = size;
- entry->page_order = page_order;
-
- offset = 0;
-
- while (entry->buf_count < count) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
-
- buf->offset = (dma->byte_count + offset);
- buf->bus_address = agp_offset + offset;
- buf->address = (void *)(agp_offset + offset);
- buf->next = NULL;
- buf->waiting = 0;
- buf->pending = 0;
- buf->file_priv = NULL;
-
- buf->dev_priv_size = dev->driver->dev_priv_size;
- buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
- if (!buf->dev_private) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- drm_cleanup_buf_error(dev, entry);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
-
- offset += alignment;
- entry->buf_count++;
- byte_count += PAGE_SIZE << page_order;
- }
-
- DRM_DEBUG("byte_count: %d\n", byte_count);
-
- temp_buflist = krealloc(dma->buflist,
- (dma->buf_count + entry->buf_count) *
- sizeof(*dma->buflist), GFP_KERNEL);
- if (!temp_buflist) {
- /* Free the entry because it isn't valid */
- drm_cleanup_buf_error(dev, entry);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- dma->buflist = temp_buflist;
-
- for (i = 0; i < entry->buf_count; i++) {
- dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
-
- dma->buf_count += entry->buf_count;
- dma->seg_count += entry->seg_count;
- dma->page_count += byte_count >> PAGE_SHIFT;
- dma->byte_count += byte_count;
-
- DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
- DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
-
- mutex_unlock(&dev->struct_mutex);
-
- request->count = entry->buf_count;
- request->size = size;
-
- dma->flags = _DRM_DMA_USE_AGP;
-
- atomic_dec(&dev->buf_alloc);
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_addbufs_agp);
-#endif /* CONFIG_AGP */
-
-int drm_legacy_addbufs_pci(struct drm_device *dev,
- struct drm_buf_desc *request)
-{
- struct drm_device_dma *dma = dev->dma;
- int count;
- int order;
- int size;
- int total;
- int page_order;
- struct drm_buf_entry *entry;
- drm_dma_handle_t *dmah;
- struct drm_buf *buf;
- int alignment;
- unsigned long offset;
- int i;
- int byte_count;
- int page_count;
- unsigned long *temp_pagelist;
- struct drm_buf **temp_buflist;
-
- if (!drm_core_check_feature(dev, DRIVER_PCI_DMA))
- return -EOPNOTSUPP;
-
- if (!dma)
- return -EINVAL;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- count = request->count;
- order = order_base_2(request->size);
- size = 1 << order;
-
- DRM_DEBUG("count=%d, size=%d (%d), order=%d\n",
- request->count, request->size, size, order);
-
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return -EINVAL;
-
- alignment = (request->flags & _DRM_PAGE_ALIGN)
- ? PAGE_ALIGN(size) : size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
- spin_lock(&dev->buf_lock);
- if (dev->buf_use) {
- spin_unlock(&dev->buf_lock);
- return -EBUSY;
- }
- atomic_inc(&dev->buf_alloc);
- spin_unlock(&dev->buf_lock);
-
- mutex_lock(&dev->struct_mutex);
- entry = &dma->bufs[order];
- if (entry->buf_count) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM; /* May only call once for each order */
- }
-
- if (count < 0 || count > 4096) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -EINVAL;
- }
-
- entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
- if (!entry->buflist) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- entry->seglist = kcalloc(count, sizeof(*entry->seglist), GFP_KERNEL);
- if (!entry->seglist) {
- kfree(entry->buflist);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- /* Keep the original pagelist until we know all the allocations
- * have succeeded
- */
- temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
- sizeof(*dma->pagelist),
- GFP_KERNEL);
- if (!temp_pagelist) {
- kfree(entry->buflist);
- kfree(entry->seglist);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- memcpy(temp_pagelist,
- dma->pagelist, dma->page_count * sizeof(*dma->pagelist));
- DRM_DEBUG("pagelist: %d entries\n",
- dma->page_count + (count << page_order));
-
- entry->buf_size = size;
- entry->page_order = page_order;
- byte_count = 0;
- page_count = 0;
-
- while (entry->buf_count < count) {
- dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
- if (!dmah) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- entry->seg_count = count;
- drm_cleanup_buf_error(dev, entry);
- kfree(temp_pagelist);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- dmah->size = total;
- dmah->vaddr = dma_alloc_coherent(dev->dev,
- dmah->size,
- &dmah->busaddr,
- GFP_KERNEL);
- if (!dmah->vaddr) {
- kfree(dmah);
-
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- entry->seg_count = count;
- drm_cleanup_buf_error(dev, entry);
- kfree(temp_pagelist);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- entry->seglist[entry->seg_count++] = dmah;
- for (i = 0; i < (1 << page_order); i++) {
- DRM_DEBUG("page %d @ 0x%08lx\n",
- dma->page_count + page_count,
- (unsigned long)dmah->vaddr + PAGE_SIZE * i);
- temp_pagelist[dma->page_count + page_count++]
- = (unsigned long)dmah->vaddr + PAGE_SIZE * i;
- }
- for (offset = 0;
- offset + size <= total && entry->buf_count < count;
- offset += alignment, ++entry->buf_count) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
- buf->offset = (dma->byte_count + byte_count + offset);
- buf->address = (void *)(dmah->vaddr + offset);
- buf->bus_address = dmah->busaddr + offset;
- buf->next = NULL;
- buf->waiting = 0;
- buf->pending = 0;
- buf->file_priv = NULL;
-
- buf->dev_priv_size = dev->driver->dev_priv_size;
- buf->dev_private = kzalloc(buf->dev_priv_size,
- GFP_KERNEL);
- if (!buf->dev_private) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- entry->seg_count = count;
- drm_cleanup_buf_error(dev, entry);
- kfree(temp_pagelist);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- DRM_DEBUG("buffer %d @ %p\n",
- entry->buf_count, buf->address);
- }
- byte_count += PAGE_SIZE << page_order;
- }
-
- temp_buflist = krealloc(dma->buflist,
- (dma->buf_count + entry->buf_count) *
- sizeof(*dma->buflist), GFP_KERNEL);
- if (!temp_buflist) {
- /* Free the entry because it isn't valid */
- drm_cleanup_buf_error(dev, entry);
- kfree(temp_pagelist);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- dma->buflist = temp_buflist;
-
- for (i = 0; i < entry->buf_count; i++) {
- dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
-
- /* No allocations failed, so now we can replace the original pagelist
- * with the new one.
- */
- if (dma->page_count) {
- kfree(dma->pagelist);
- }
- dma->pagelist = temp_pagelist;
-
- dma->buf_count += entry->buf_count;
- dma->seg_count += entry->seg_count;
- dma->page_count += entry->seg_count << page_order;
- dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
-
- mutex_unlock(&dev->struct_mutex);
-
- request->count = entry->buf_count;
- request->size = size;
-
- if (request->flags & _DRM_PCI_BUFFER_RO)
- dma->flags = _DRM_DMA_USE_PCI_RO;
-
- atomic_dec(&dev->buf_alloc);
- return 0;
-
-}
-EXPORT_SYMBOL(drm_legacy_addbufs_pci);
-
-static int drm_legacy_addbufs_sg(struct drm_device *dev,
- struct drm_buf_desc *request)
-{
- struct drm_device_dma *dma = dev->dma;
- struct drm_buf_entry *entry;
- struct drm_buf *buf;
- unsigned long offset;
- unsigned long agp_offset;
- int count;
- int order;
- int size;
- int alignment;
- int page_order;
- int total;
- int byte_count;
- int i;
- struct drm_buf **temp_buflist;
-
- if (!drm_core_check_feature(dev, DRIVER_SG))
- return -EOPNOTSUPP;
-
- if (!dma)
- return -EINVAL;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- count = request->count;
- order = order_base_2(request->size);
- size = 1 << order;
-
- alignment = (request->flags & _DRM_PAGE_ALIGN)
- ? PAGE_ALIGN(size) : size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
- byte_count = 0;
- agp_offset = request->agp_start;
-
- DRM_DEBUG("count: %d\n", count);
- DRM_DEBUG("order: %d\n", order);
- DRM_DEBUG("size: %d\n", size);
- DRM_DEBUG("agp_offset: %lu\n", agp_offset);
- DRM_DEBUG("alignment: %d\n", alignment);
- DRM_DEBUG("page_order: %d\n", page_order);
- DRM_DEBUG("total: %d\n", total);
-
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return -EINVAL;
-
- spin_lock(&dev->buf_lock);
- if (dev->buf_use) {
- spin_unlock(&dev->buf_lock);
- return -EBUSY;
- }
- atomic_inc(&dev->buf_alloc);
- spin_unlock(&dev->buf_lock);
-
- mutex_lock(&dev->struct_mutex);
- entry = &dma->bufs[order];
- if (entry->buf_count) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM; /* May only call once for each order */
- }
-
- if (count < 0 || count > 4096) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -EINVAL;
- }
-
- entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
- if (!entry->buflist) {
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- entry->buf_size = size;
- entry->page_order = page_order;
-
- offset = 0;
-
- while (entry->buf_count < count) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
-
- buf->offset = (dma->byte_count + offset);
- buf->bus_address = agp_offset + offset;
- buf->address = (void *)(agp_offset + offset
- + (unsigned long)dev->sg->virtual);
- buf->next = NULL;
- buf->waiting = 0;
- buf->pending = 0;
- buf->file_priv = NULL;
-
- buf->dev_priv_size = dev->driver->dev_priv_size;
- buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
- if (!buf->dev_private) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- drm_cleanup_buf_error(dev, entry);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
-
- DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
-
- offset += alignment;
- entry->buf_count++;
- byte_count += PAGE_SIZE << page_order;
- }
-
- DRM_DEBUG("byte_count: %d\n", byte_count);
-
- temp_buflist = krealloc(dma->buflist,
- (dma->buf_count + entry->buf_count) *
- sizeof(*dma->buflist), GFP_KERNEL);
- if (!temp_buflist) {
- /* Free the entry because it isn't valid */
- drm_cleanup_buf_error(dev, entry);
- mutex_unlock(&dev->struct_mutex);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- dma->buflist = temp_buflist;
-
- for (i = 0; i < entry->buf_count; i++) {
- dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
-
- dma->buf_count += entry->buf_count;
- dma->seg_count += entry->seg_count;
- dma->page_count += byte_count >> PAGE_SHIFT;
- dma->byte_count += byte_count;
-
- DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
- DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
-
- mutex_unlock(&dev->struct_mutex);
-
- request->count = entry->buf_count;
- request->size = size;
-
- dma->flags = _DRM_DMA_USE_SG;
-
- atomic_dec(&dev->buf_alloc);
- return 0;
-}
-
-/*
- * Add buffers for DMA transfers (ioctl).
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg pointer to a struct drm_buf_desc request.
- * \return zero on success or a negative number on failure.
- *
- * According with the memory type specified in drm_buf_desc::flags and the
- * build options, it dispatches the call either to addbufs_agp(),
- * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
- * PCI memory respectively.
- */
-int drm_legacy_addbufs(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_buf_desc *request = data;
- int ret;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- return -EOPNOTSUPP;
-
-#if IS_ENABLED(CONFIG_AGP)
- if (request->flags & _DRM_AGP_BUFFER)
- ret = drm_legacy_addbufs_agp(dev, request);
- else
-#endif
- if (request->flags & _DRM_SG_BUFFER)
- ret = drm_legacy_addbufs_sg(dev, request);
- else if (request->flags & _DRM_FB_BUFFER)
- ret = -EINVAL;
- else
- ret = drm_legacy_addbufs_pci(dev, request);
-
- return ret;
-}
-
-/*
- * Get information about the buffer mappings.
- *
- * This was originally mean for debugging purposes, or by a sophisticated
- * client library to determine how best to use the available buffers (e.g.,
- * large buffers can be used for image transfer).
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg pointer to a drm_buf_info structure.
- * \return zero on success or a negative number on failure.
- *
- * Increments drm_device::buf_use while holding the drm_device::buf_lock
- * lock, preventing of allocating more buffers after this call. Information
- * about each requested buffer is then copied into user space.
- */
-int __drm_legacy_infobufs(struct drm_device *dev,
- void *data, int *p,
- int (*f)(void *, int, struct drm_buf_entry *))
-{
- struct drm_device_dma *dma = dev->dma;
- int i;
- int count;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- return -EOPNOTSUPP;
-
- if (!dma)
- return -EINVAL;
-
- spin_lock(&dev->buf_lock);
- if (atomic_read(&dev->buf_alloc)) {
- spin_unlock(&dev->buf_lock);
- return -EBUSY;
- }
- ++dev->buf_use; /* Can't allocate more after this call */
- spin_unlock(&dev->buf_lock);
-
- for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
- if (dma->bufs[i].buf_count)
- ++count;
- }
-
- DRM_DEBUG("count = %d\n", count);
-
- if (*p >= count) {
- for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
- struct drm_buf_entry *from = &dma->bufs[i];
-
- if (from->buf_count) {
- if (f(data, count, from) < 0)
- return -EFAULT;
- DRM_DEBUG("%d %d %d %d %d\n",
- i,
- dma->bufs[i].buf_count,
- dma->bufs[i].buf_size,
- dma->bufs[i].low_mark,
- dma->bufs[i].high_mark);
- ++count;
- }
- }
- }
- *p = count;
-
- return 0;
-}
-
-static int copy_one_buf(void *data, int count, struct drm_buf_entry *from)
-{
- struct drm_buf_info *request = data;
- struct drm_buf_desc __user *to = &request->list[count];
- struct drm_buf_desc v = {.count = from->buf_count,
- .size = from->buf_size,
- .low_mark = from->low_mark,
- .high_mark = from->high_mark};
-
- if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags)))
- return -EFAULT;
- return 0;
-}
-
-int drm_legacy_infobufs(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_buf_info *request = data;
-
- return __drm_legacy_infobufs(dev, data, &request->count, copy_one_buf);
-}
-
-/*
- * Specifies a low and high water mark for buffer allocation
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg a pointer to a drm_buf_desc structure.
- * \return zero on success or a negative number on failure.
- *
- * Verifies that the size order is bounded between the admissible orders and
- * updates the respective drm_device_dma::bufs entry low and high water mark.
- *
- * \note This ioctl is deprecated and mostly never used.
- */
-int drm_legacy_markbufs(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_device_dma *dma = dev->dma;
- struct drm_buf_desc *request = data;
- int order;
- struct drm_buf_entry *entry;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- return -EOPNOTSUPP;
-
- if (!dma)
- return -EINVAL;
-
- DRM_DEBUG("%d, %d, %d\n",
- request->size, request->low_mark, request->high_mark);
- order = order_base_2(request->size);
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return -EINVAL;
- entry = &dma->bufs[order];
-
- if (request->low_mark < 0 || request->low_mark > entry->buf_count)
- return -EINVAL;
- if (request->high_mark < 0 || request->high_mark > entry->buf_count)
- return -EINVAL;
-
- entry->low_mark = request->low_mark;
- entry->high_mark = request->high_mark;
-
- return 0;
-}
-
-/*
- * Unreserve the buffers in list, previously reserved using drmDMA.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg pointer to a drm_buf_free structure.
- * \return zero on success or a negative number on failure.
- *
- * Calls free_buffer() for each used buffer.
- * This function is primarily used for debugging.
- */
-int drm_legacy_freebufs(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_device_dma *dma = dev->dma;
- struct drm_buf_free *request = data;
- int i;
- int idx;
- struct drm_buf *buf;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- return -EOPNOTSUPP;
-
- if (!dma)
- return -EINVAL;
-
- DRM_DEBUG("%d\n", request->count);
- for (i = 0; i < request->count; i++) {
- if (copy_from_user(&idx, &request->list[i], sizeof(idx)))
- return -EFAULT;
- if (idx < 0 || idx >= dma->buf_count) {
- DRM_ERROR("Index %d (of %d max)\n",
- idx, dma->buf_count - 1);
- return -EINVAL;
- }
- idx = array_index_nospec(idx, dma->buf_count);
- buf = dma->buflist[idx];
- if (buf->file_priv != file_priv) {
- DRM_ERROR("Process %d freeing buffer not owned\n",
- task_pid_nr(current));
- return -EINVAL;
- }
- drm_legacy_free_buffer(dev, buf);
- }
-
- return 0;
-}
-
-/*
- * Maps all of the DMA buffers into client-virtual space (ioctl).
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg pointer to a drm_buf_map structure.
- * \return zero on success or a negative number on failure.
- *
- * Maps the AGP, SG or PCI buffer region with vm_mmap(), and copies information
- * about each buffer into user space. For PCI buffers, it calls vm_mmap() with
- * offset equal to 0, which drm_mmap() interprets as PCI buffers and calls
- * drm_mmap_dma().
- */
-int __drm_legacy_mapbufs(struct drm_device *dev, void *data, int *p,
- void __user **v,
- int (*f)(void *, int, unsigned long,
- struct drm_buf *),
- struct drm_file *file_priv)
-{
- struct drm_device_dma *dma = dev->dma;
- int retcode = 0;
- unsigned long virtual;
- int i;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
- return -EOPNOTSUPP;
-
- if (!dma)
- return -EINVAL;
-
- spin_lock(&dev->buf_lock);
- if (atomic_read(&dev->buf_alloc)) {
- spin_unlock(&dev->buf_lock);
- return -EBUSY;
- }
- dev->buf_use++; /* Can't allocate more after this call */
- spin_unlock(&dev->buf_lock);
-
- if (*p >= dma->buf_count) {
- if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP))
- || (drm_core_check_feature(dev, DRIVER_SG)
- && (dma->flags & _DRM_DMA_USE_SG))) {
- struct drm_local_map *map = dev->agp_buffer_map;
- unsigned long token = dev->agp_buffer_token;
-
- if (!map) {
- retcode = -EINVAL;
- goto done;
- }
- virtual = vm_mmap(file_priv->filp, 0, map->size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- token);
- } else {
- virtual = vm_mmap(file_priv->filp, 0, dma->byte_count,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, 0);
- }
- if (virtual > -1024UL) {
- /* Real error */
- retcode = (signed long)virtual;
- goto done;
- }
- *v = (void __user *)virtual;
-
- for (i = 0; i < dma->buf_count; i++) {
- if (f(data, i, virtual, dma->buflist[i]) < 0) {
- retcode = -EFAULT;
- goto done;
- }
- }
- }
- done:
- *p = dma->buf_count;
- DRM_DEBUG("%d buffers, retcode = %d\n", *p, retcode);
-
- return retcode;
-}
-
-static int map_one_buf(void *data, int idx, unsigned long virtual,
- struct drm_buf *buf)
-{
- struct drm_buf_map *request = data;
- unsigned long address = virtual + buf->offset; /* *** */
-
- if (copy_to_user(&request->list[idx].idx, &buf->idx,
- sizeof(request->list[0].idx)))
- return -EFAULT;
- if (copy_to_user(&request->list[idx].total, &buf->total,
- sizeof(request->list[0].total)))
- return -EFAULT;
- if (clear_user(&request->list[idx].used, sizeof(int)))
- return -EFAULT;
- if (copy_to_user(&request->list[idx].address, &address,
- sizeof(address)))
- return -EFAULT;
- return 0;
-}
-
-int drm_legacy_mapbufs(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_buf_map *request = data;
-
- return __drm_legacy_mapbufs(dev, data, &request->count,
- &request->virtual, map_one_buf,
- file_priv);
-}
-
-int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (dev->driver->dma_ioctl)
- return dev->driver->dma_ioctl(dev, data, file_priv);
- else
- return -EINVAL;
-}
-
-struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev)
-{
- struct drm_map_list *entry;
-
- list_for_each_entry(entry, &dev->maplist, head) {
- if (entry->map && entry->map->type == _DRM_SHM &&
- (entry->map->flags & _DRM_CONTAINS_LOCK)) {
- return entry->map;
- }
- }
- return NULL;
-}
-EXPORT_SYMBOL(drm_legacy_getsarea);
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
deleted file mode 100644
index a0fc779e5e1e8..0000000000000
--- a/drivers/gpu/drm/drm_context.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Legacy: Generic DRM Contexts
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Author: Rickard E. (Rik) Faith <faith@valinux.com>
- * Author: Gareth Hughes <gareth@valinux.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-
-#include <drm/drm_drv.h>
-#include <drm/drm_file.h>
-#include <drm/drm_print.h>
-
-#include "drm_legacy.h"
-
-struct drm_ctx_list {
- struct list_head head;
- drm_context_t handle;
- struct drm_file *tag;
-};
-
-/******************************************************************/
-/** \name Context bitmap support */
-/*@{*/
-
-/*
- * Free a handle from the context bitmap.
- *
- * \param dev DRM device.
- * \param ctx_handle context handle.
- *
- * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
- * in drm_device::ctx_idr, while holding the drm_device::struct_mutex
- * lock.
- */
-void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
-{
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- mutex_lock(&dev->struct_mutex);
- idr_remove(&dev->ctx_idr, ctx_handle);
- mutex_unlock(&dev->struct_mutex);
-}
-
-/*
- * Context bitmap allocation.
- *
- * \param dev DRM device.
- * \return (non-negative) context handle on success or a negative number on failure.
- *
- * Allocate a new idr from drm_device::ctx_idr while holding the
- * drm_device::struct_mutex lock.
- */
-static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
-{
- int ret;
-
- mutex_lock(&dev->struct_mutex);
- ret = idr_alloc(&dev->ctx_idr, NULL, DRM_RESERVED_CONTEXTS, 0,
- GFP_KERNEL);
- mutex_unlock(&dev->struct_mutex);
- return ret;
-}
-
-/*
- * Context bitmap initialization.
- *
- * \param dev DRM device.
- *
- * Initialise the drm_device::ctx_idr
- */
-void drm_legacy_ctxbitmap_init(struct drm_device * dev)
-{
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- idr_init(&dev->ctx_idr);
-}
-
-/*
- * Context bitmap cleanup.
- *
- * \param dev DRM device.
- *
- * Free all idr members using drm_ctx_sarea_free helper function
- * while holding the drm_device::struct_mutex lock.
- */
-void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
-{
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- mutex_lock(&dev->struct_mutex);
- idr_destroy(&dev->ctx_idr);
- mutex_unlock(&dev->struct_mutex);
-}
-
-/**
- * drm_legacy_ctxbitmap_flush() - Flush all contexts owned by a file
- * @dev: DRM device to operate on
- * @file: Open file to flush contexts for
- *
- * This iterates over all contexts on @dev and drops them if they're owned by
- * @file. Note that after this call returns, new contexts might be added if
- * the file is still alive.
- */
-void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
-{
- struct drm_ctx_list *pos, *tmp;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- mutex_lock(&dev->ctxlist_mutex);
-
- list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
- if (pos->tag == file &&
- pos->handle != DRM_KERNEL_CONTEXT) {
- if (dev->driver->context_dtor)
- dev->driver->context_dtor(dev, pos->handle);
-
- drm_legacy_ctxbitmap_free(dev, pos->handle);
- list_del(&pos->head);
- kfree(pos);
- }
- }
-
- mutex_unlock(&dev->ctxlist_mutex);
-}
-
-/*@}*/
-
-/******************************************************************/
-/** \name Per Context SAREA Support */
-/*@{*/
-
-/*
- * Get per-context SAREA.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx_priv_map structure.
- * \return zero on success or a negative number on failure.
- *
- * Gets the map from drm_device::ctx_idr with the handle specified and
- * returns its handle.
- */
-int drm_legacy_getsareactx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx_priv_map *request = data;
- struct drm_local_map *map;
- struct drm_map_list *_entry;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- mutex_lock(&dev->struct_mutex);
-
- map = idr_find(&dev->ctx_idr, request->ctx_id);
- if (!map) {
- mutex_unlock(&dev->struct_mutex);
- return -EINVAL;
- }
-
- request->handle = NULL;
- list_for_each_entry(_entry, &dev->maplist, head) {
- if (_entry->map == map) {
- request->handle =
- (void *)(unsigned long)_entry->user_token;
- break;
- }
- }
-
- mutex_unlock(&dev->struct_mutex);
-
- if (request->handle == NULL)
- return -EINVAL;
-
- return 0;
-}
-
-/*
- * Set per-context SAREA.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx_priv_map structure.
- * \return zero on success or a negative number on failure.
- *
- * Searches the mapping specified in \p arg and update the entry in
- * drm_device::ctx_idr with it.
- */
-int drm_legacy_setsareactx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx_priv_map *request = data;
- struct drm_local_map *map = NULL;
- struct drm_map_list *r_list = NULL;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- mutex_lock(&dev->struct_mutex);
- list_for_each_entry(r_list, &dev->maplist, head) {
- if (r_list->map
- && r_list->user_token == (unsigned long) request->handle)
- goto found;
- }
- bad:
- mutex_unlock(&dev->struct_mutex);
- return -EINVAL;
-
- found:
- map = r_list->map;
- if (!map)
- goto bad;
-
- if (IS_ERR(idr_replace(&dev->ctx_idr, map, request->ctx_id)))
- goto bad;
-
- mutex_unlock(&dev->struct_mutex);
-
- return 0;
-}
-
-/*@}*/
-
-/******************************************************************/
-/** \name The actual DRM context handling routines */
-/*@{*/
-
-/*
- * Switch context.
- *
- * \param dev DRM device.
- * \param old old context handle.
- * \param new new context handle.
- * \return zero on success or a negative number on failure.
- *
- * Attempt to set drm_device::context_flag.
- */
-static int drm_context_switch(struct drm_device * dev, int old, int new)
-{
- if (test_and_set_bit(0, &dev->context_flag)) {
- DRM_ERROR("Reentering -- FIXME\n");
- return -EBUSY;
- }
-
- DRM_DEBUG("Context switch from %d to %d\n", old, new);
-
- if (new == dev->last_context) {
- clear_bit(0, &dev->context_flag);
- return 0;
- }
-
- return 0;
-}
-
-/*
- * Complete context switch.
- *
- * \param dev DRM device.
- * \param new new context handle.
- * \return zero on success or a negative number on failure.
- *
- * Updates drm_device::last_context and drm_device::last_switch. Verifies the
- * hardware lock is held, clears the drm_device::context_flag and wakes up
- * drm_device::context_wait.
- */
-static int drm_context_switch_complete(struct drm_device *dev,
- struct drm_file *file_priv, int new)
-{
- dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
-
- if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
- DRM_ERROR("Lock isn't held after context switch\n");
- }
-
- /* If a context switch is ever initiated
- when the kernel holds the lock, release
- that lock here.
- */
- clear_bit(0, &dev->context_flag);
-
- return 0;
-}
-
-/*
- * Reserve contexts.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx_res structure.
- * \return zero on success or a negative number on failure.
- */
-int drm_legacy_resctx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx_res *res = data;
- struct drm_ctx ctx;
- int i;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (res->count >= DRM_RESERVED_CONTEXTS) {
- memset(&ctx, 0, sizeof(ctx));
- for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
- ctx.handle = i;
- if (copy_to_user(&res->contexts[i], &ctx, sizeof(ctx)))
- return -EFAULT;
- }
- }
- res->count = DRM_RESERVED_CONTEXTS;
-
- return 0;
-}
-
-/*
- * Add context.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx structure.
- * \return zero on success or a negative number on failure.
- *
- * Get a new handle for the context and copy to userspace.
- */
-int drm_legacy_addctx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx_list *ctx_entry;
- struct drm_ctx *ctx = data;
- int tmp_handle;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- tmp_handle = drm_legacy_ctxbitmap_next(dev);
- if (tmp_handle == DRM_KERNEL_CONTEXT) {
- /* Skip kernel's context and get a new one. */
- tmp_handle = drm_legacy_ctxbitmap_next(dev);
- }
- DRM_DEBUG("%d\n", tmp_handle);
- if (tmp_handle < 0) {
- DRM_DEBUG("Not enough free contexts.\n");
- /* Should this return -EBUSY instead? */
- return tmp_handle;
- }
-
- ctx->handle = tmp_handle;
-
- ctx_entry = kmalloc(sizeof(*ctx_entry), GFP_KERNEL);
- if (!ctx_entry) {
- DRM_DEBUG("out of memory\n");
- return -ENOMEM;
- }
-
- INIT_LIST_HEAD(&ctx_entry->head);
- ctx_entry->handle = ctx->handle;
- ctx_entry->tag = file_priv;
-
- mutex_lock(&dev->ctxlist_mutex);
- list_add(&ctx_entry->head, &dev->ctxlist);
- mutex_unlock(&dev->ctxlist_mutex);
-
- return 0;
-}
-
-/*
- * Get context.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx structure.
- * \return zero on success or a negative number on failure.
- */
-int drm_legacy_getctx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx *ctx = data;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- /* This is 0, because we don't handle any context flags */
- ctx->flags = 0;
-
- return 0;
-}
-
-/*
- * Switch context.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx structure.
- * \return zero on success or a negative number on failure.
- *
- * Calls context_switch().
- */
-int drm_legacy_switchctx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx *ctx = data;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- DRM_DEBUG("%d\n", ctx->handle);
- return drm_context_switch(dev, dev->last_context, ctx->handle);
-}
-
-/*
- * New context.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx structure.
- * \return zero on success or a negative number on failure.
- *
- * Calls context_switch_complete().
- */
-int drm_legacy_newctx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx *ctx = data;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- DRM_DEBUG("%d\n", ctx->handle);
- drm_context_switch_complete(dev, file_priv, ctx->handle);
-
- return 0;
-}
-
-/*
- * Remove context.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument pointing to a drm_ctx structure.
- * \return zero on success or a negative number on failure.
- *
- * If not the special kernel context, calls ctxbitmap_free() to free the specified context.
- */
-int drm_legacy_rmctx(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_ctx *ctx = data;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- DRM_DEBUG("%d\n", ctx->handle);
- if (ctx->handle != DRM_KERNEL_CONTEXT) {
- if (dev->driver->context_dtor)
- dev->driver->context_dtor(dev, ctx->handle);
- drm_legacy_ctxbitmap_free(dev, ctx->handle);
- }
-
- mutex_lock(&dev->ctxlist_mutex);
- if (!list_empty(&dev->ctxlist)) {
- struct drm_ctx_list *pos, *n;
-
- list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
- if (pos->handle == ctx->handle) {
- list_del(&pos->head);
- kfree(pos);
- }
- }
- }
- mutex_unlock(&dev->ctxlist_mutex);
-
- return 0;
-}
-
-/*@}*/
diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
deleted file mode 100644
index eb6b741a6f995..0000000000000
--- a/drivers/gpu/drm/drm_dma.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * \file drm_dma.c
- * DMA IOCTL and function support
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/export.h>
-#include <linux/pci.h>
-
-#include <drm/drm_drv.h>
-#include <drm/drm_print.h>
-
-#include "drm_legacy.h"
-
-/**
- * drm_legacy_dma_setup() - Initialize the DMA data.
- *
- * @dev: DRM device.
- * Return: zero on success or a negative value on failure.
- *
- * Allocate and initialize a drm_device_dma structure.
- */
-int drm_legacy_dma_setup(struct drm_device *dev)
-{
- int i;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
- !drm_core_check_feature(dev, DRIVER_LEGACY))
- return 0;
-
- dev->buf_use = 0;
- atomic_set(&dev->buf_alloc, 0);
-
- dev->dma = kzalloc(sizeof(*dev->dma), GFP_KERNEL);
- if (!dev->dma)
- return -ENOMEM;
-
- for (i = 0; i <= DRM_MAX_ORDER; i++)
- memset(&dev->dma->bufs[i], 0, sizeof(dev->dma->bufs[0]));
-
- return 0;
-}
-
-/**
- * drm_legacy_dma_takedown() - Cleanup the DMA resources.
- *
- * @dev: DRM device.
- *
- * Free all pages associated with DMA buffers, the buffers and pages lists, and
- * finally the drm_device::dma structure itself.
- */
-void drm_legacy_dma_takedown(struct drm_device *dev)
-{
- struct drm_device_dma *dma = dev->dma;
- drm_dma_handle_t *dmah;
- int i, j;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
- !drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- if (!dma)
- return;
-
- /* Clear dma buffers */
- for (i = 0; i <= DRM_MAX_ORDER; i++) {
- if (dma->bufs[i].seg_count) {
- DRM_DEBUG("order %d: buf_count = %d,"
- " seg_count = %d\n",
- i,
- dma->bufs[i].buf_count,
- dma->bufs[i].seg_count);
- for (j = 0; j < dma->bufs[i].seg_count; j++) {
- if (dma->bufs[i].seglist[j]) {
- dmah = dma->bufs[i].seglist[j];
- dma_free_coherent(dev->dev,
- dmah->size,
- dmah->vaddr,
- dmah->busaddr);
- kfree(dmah);
- }
- }
- kfree(dma->bufs[i].seglist);
- }
- if (dma->bufs[i].buf_count) {
- for (j = 0; j < dma->bufs[i].buf_count; j++) {
- kfree(dma->bufs[i].buflist[j].dev_private);
- }
- kfree(dma->bufs[i].buflist);
- }
- }
-
- kfree(dma->buflist);
- kfree(dma->pagelist);
- kfree(dev->dma);
- dev->dma = NULL;
-}
-
-/**
- * drm_legacy_free_buffer() - Free a buffer.
- *
- * @dev: DRM device.
- * @buf: buffer to free.
- *
- * Resets the fields of \p buf.
- */
-void drm_legacy_free_buffer(struct drm_device *dev, struct drm_buf * buf)
-{
- if (!buf)
- return;
-
- buf->waiting = 0;
- buf->pending = 0;
- buf->file_priv = NULL;
- buf->used = 0;
-}
-
-/**
- * drm_legacy_reclaim_buffers() - Reclaim the buffers.
- *
- * @dev: DRM device.
- * @file_priv: DRM file private.
- *
- * Frees each buffer associated with \p file_priv not already on the hardware.
- */
-void drm_legacy_reclaim_buffers(struct drm_device *dev,
- struct drm_file *file_priv)
-{
- struct drm_device_dma *dma = dev->dma;
- int i;
-
- if (!dma)
- return;
- for (i = 0; i < dma->buf_count; i++) {
- if (dma->buflist[i]->file_priv == file_priv) {
- switch (dma->buflist[i]->list) {
- case DRM_LIST_NONE:
- drm_legacy_free_buffer(dev, dma->buflist[i]);
- break;
- case DRM_LIST_WAIT:
- dma->buflist[i]->list = DRM_LIST_RECLAIM;
- break;
- default:
- /* Buffer already on hardware. */
- break;
- }
- }
- }
-}
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c
deleted file mode 100644
index 60afa18655599..0000000000000
--- a/drivers/gpu/drm/drm_hashtab.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- **************************************************************************/
-/*
- * Simple open hash tab implementation.
- *
- * Authors:
- * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <linux/hash.h>
-#include <linux/mm.h>
-#include <linux/rculist.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-
-#include <drm/drm_print.h>
-
-#include "drm_legacy.h"
-
-int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
-{
- unsigned int size = 1 << order;
-
- ht->order = order;
- ht->table = NULL;
- if (size <= PAGE_SIZE / sizeof(*ht->table))
- ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL);
- else
- ht->table = vzalloc(array_size(size, sizeof(*ht->table)));
- if (!ht->table) {
- DRM_ERROR("Out of memory for hash table\n");
- return -ENOMEM;
- }
- return 0;
-}
-
-void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key)
-{
- struct drm_hash_item *entry;
- struct hlist_head *h_list;
- unsigned int hashed_key;
- int count = 0;
-
- hashed_key = hash_long(key, ht->order);
- DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key);
- h_list = &ht->table[hashed_key];
- hlist_for_each_entry(entry, h_list, head)
- DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key);
-}
-
-static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht,
- unsigned long key)
-{
- struct drm_hash_item *entry;
- struct hlist_head *h_list;
- unsigned int hashed_key;
-
- hashed_key = hash_long(key, ht->order);
- h_list = &ht->table[hashed_key];
- hlist_for_each_entry(entry, h_list, head) {
- if (entry->key == key)
- return &entry->head;
- if (entry->key > key)
- break;
- }
- return NULL;
-}
-
-static struct hlist_node *drm_ht_find_key_rcu(struct drm_open_hash *ht,
- unsigned long key)
-{
- struct drm_hash_item *entry;
- struct hlist_head *h_list;
- unsigned int hashed_key;
-
- hashed_key = hash_long(key, ht->order);
- h_list = &ht->table[hashed_key];
- hlist_for_each_entry_rcu(entry, h_list, head) {
- if (entry->key == key)
- return &entry->head;
- if (entry->key > key)
- break;
- }
- return NULL;
-}
-
-int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item)
-{
- struct drm_hash_item *entry;
- struct hlist_head *h_list;
- struct hlist_node *parent;
- unsigned int hashed_key;
- unsigned long key = item->key;
-
- hashed_key = hash_long(key, ht->order);
- h_list = &ht->table[hashed_key];
- parent = NULL;
- hlist_for_each_entry(entry, h_list, head) {
- if (entry->key == key)
- return -EINVAL;
- if (entry->key > key)
- break;
- parent = &entry->head;
- }
- if (parent) {
- hlist_add_behind_rcu(&item->head, parent);
- } else {
- hlist_add_head_rcu(&item->head, h_list);
- }
- return 0;
-}
-
-/*
- * Just insert an item and return any "bits" bit key that hasn't been
- * used before.
- */
-int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
- unsigned long seed, int bits, int shift,
- unsigned long add)
-{
- int ret;
- unsigned long mask = (1UL << bits) - 1;
- unsigned long first, unshifted_key;
-
- unshifted_key = hash_long(seed, bits);
- first = unshifted_key;
- do {
- item->key = (unshifted_key << shift) + add;
- ret = drm_ht_insert_item(ht, item);
- if (ret)
- unshifted_key = (unshifted_key + 1) & mask;
- } while(ret && (unshifted_key != first));
-
- if (ret) {
- DRM_ERROR("Available key bit space exhausted\n");
- return -EINVAL;
- }
- return 0;
-}
-
-int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key,
- struct drm_hash_item **item)
-{
- struct hlist_node *list;
-
- list = drm_ht_find_key_rcu(ht, key);
- if (!list)
- return -EINVAL;
-
- *item = hlist_entry(list, struct drm_hash_item, head);
- return 0;
-}
-
-int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key)
-{
- struct hlist_node *list;
-
- list = drm_ht_find_key(ht, key);
- if (list) {
- hlist_del_init_rcu(list);
- return 0;
- }
- return -EINVAL;
-}
-
-int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item)
-{
- hlist_del_init_rcu(&item->head);
- return 0;
-}
-
-void drm_ht_remove(struct drm_open_hash *ht)
-{
- if (ht->table) {
- kvfree(ht->table);
- ht->table = NULL;
- }
-}
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index a538a48c7d952..abeb51092e184 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -121,11 +121,6 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
/* drm_irq.c */
/* IOCTLS */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int drm_legacy_irq_control(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-#endif
-
int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
deleted file mode 100644
index d327638e15ee7..0000000000000
--- a/drivers/gpu/drm/drm_irq.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * drm_irq.c IRQ and vblank support
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#include <linux/export.h>
-#include <linux/interrupt.h> /* For task queue support */
-#include <linux/pci.h>
-#include <linux/vgaarb.h>
-
-#include <drm/drm.h>
-#include <drm/drm_device.h>
-#include <drm/drm_drv.h>
-#include <drm/drm_legacy.h>
-#include <drm/drm_print.h>
-#include <drm/drm_vblank.h>
-
-#include "drm_internal.h"
-
-static int drm_legacy_irq_install(struct drm_device *dev, int irq)
-{
- int ret;
- unsigned long sh_flags = 0;
-
- if (irq == 0)
- return -EINVAL;
-
- if (dev->irq_enabled)
- return -EBUSY;
- dev->irq_enabled = true;
-
- DRM_DEBUG("irq=%d\n", irq);
-
- /* Before installing handler */
- if (dev->driver->irq_preinstall)
- dev->driver->irq_preinstall(dev);
-
- /* PCI devices require shared interrupts. */
- if (dev_is_pci(dev->dev))
- sh_flags = IRQF_SHARED;
-
- ret = request_irq(irq, dev->driver->irq_handler,
- sh_flags, dev->driver->name, dev);
-
- if (ret < 0) {
- dev->irq_enabled = false;
- return ret;
- }
-
- /* After installing handler */
- if (dev->driver->irq_postinstall)
- ret = dev->driver->irq_postinstall(dev);
-
- if (ret < 0) {
- dev->irq_enabled = false;
- if (drm_core_check_feature(dev, DRIVER_LEGACY))
- vga_client_unregister(to_pci_dev(dev->dev));
- free_irq(irq, dev);
- } else {
- dev->irq = irq;
- }
-
- return ret;
-}
-
-int drm_legacy_irq_uninstall(struct drm_device *dev)
-{
- unsigned long irqflags;
- bool irq_enabled;
- int i;
-
- irq_enabled = dev->irq_enabled;
- dev->irq_enabled = false;
-
- /*
- * Wake up any waiters so they don't hang. This is just to paper over
- * issues for UMS drivers which aren't in full control of their
- * vblank/irq handling. KMS drivers must ensure that vblanks are all
- * disabled when uninstalling the irq handler.
- */
- if (drm_dev_has_vblank(dev)) {
- spin_lock_irqsave(&dev->vbl_lock, irqflags);
- for (i = 0; i < dev->num_crtcs; i++) {
- struct drm_vblank_crtc *vblank = &dev->vblank[i];
-
- if (!vblank->enabled)
- continue;
-
- WARN_ON(drm_core_check_feature(dev, DRIVER_MODESET));
-
- drm_vblank_disable_and_save(dev, i);
- wake_up(&vblank->queue);
- }
- spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
- }
-
- if (!irq_enabled)
- return -EINVAL;
-
- DRM_DEBUG("irq=%d\n", dev->irq);
-
- if (drm_core_check_feature(dev, DRIVER_LEGACY))
- vga_client_unregister(to_pci_dev(dev->dev));
-
- if (dev->driver->irq_uninstall)
- dev->driver->irq_uninstall(dev);
-
- free_irq(dev->irq, dev);
-
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_irq_uninstall);
-
-int drm_legacy_irq_control(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_control *ctl = data;
- int ret = 0, irq;
- struct pci_dev *pdev;
-
- /* if we haven't irq we fallback for compatibility reasons -
- * this used to be a separate function in drm_dma.h
- */
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
- return 0;
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return 0;
- /* UMS was only ever supported on pci devices. */
- if (WARN_ON(!dev_is_pci(dev->dev)))
- return -EINVAL;
-
- switch (ctl->func) {
- case DRM_INST_HANDLER:
- pdev = to_pci_dev(dev->dev);
- irq = pdev->irq;
-
- if (dev->if_version < DRM_IF_VERSION(1, 2) &&
- ctl->irq != irq)
- return -EINVAL;
- mutex_lock(&dev->struct_mutex);
- ret = drm_legacy_irq_install(dev, irq);
- mutex_unlock(&dev->struct_mutex);
-
- return ret;
- case DRM_UNINST_HANDLER:
- mutex_lock(&dev->struct_mutex);
- ret = drm_legacy_irq_uninstall(dev);
- mutex_unlock(&dev->struct_mutex);
-
- return ret;
- default:
- return -EINVAL;
- }
-}
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
deleted file mode 100644
index 70c9dba114a61..0000000000000
--- a/drivers/gpu/drm/drm_legacy.h
+++ /dev/null
@@ -1,290 +0,0 @@
-#ifndef __DRM_LEGACY_H__
-#define __DRM_LEGACY_H__
-
-/*
- * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * This file contains legacy interfaces that modern drm drivers
- * should no longer be using. They cannot be removed as legacy
- * drivers use them, and removing them are API breaks.
- */
-#include <linux/list.h>
-
-#include <drm/drm.h>
-#include <drm/drm_device.h>
-#include <drm/drm_legacy.h>
-
-struct agp_memory;
-struct drm_buf_desc;
-struct drm_device;
-struct drm_file;
-struct drm_hash_item;
-struct drm_open_hash;
-
-/*
- * Hash-table Support
- */
-
-#define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member)
-
-/* drm_hashtab.c */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
-int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
-int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
- unsigned long seed, int bits, int shift,
- unsigned long add);
-int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item);
-
-void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key);
-int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key);
-int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item);
-void drm_ht_remove(struct drm_open_hash *ht);
-#endif
-
-/*
- * RCU-safe interface
- *
- * The user of this API needs to make sure that two or more instances of the
- * hash table manipulation functions are never run simultaneously.
- * The lookup function drm_ht_find_item_rcu may, however, run simultaneously
- * with any of the manipulation functions as long as it's called from within
- * an RCU read-locked section.
- */
-#define drm_ht_insert_item_rcu drm_ht_insert_item
-#define drm_ht_just_insert_please_rcu drm_ht_just_insert_please
-#define drm_ht_remove_key_rcu drm_ht_remove_key
-#define drm_ht_remove_item_rcu drm_ht_remove_item
-#define drm_ht_find_item_rcu drm_ht_find_item
-
-/*
- * Generic DRM Contexts
- */
-
-#define DRM_KERNEL_CONTEXT 0
-#define DRM_RESERVED_CONTEXTS 1
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_ctxbitmap_init(struct drm_device *dev);
-void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
-void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
-#else
-static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
-static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
-static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
-#endif
-
-void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
-
-int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
-#endif
-
-/*
- * Generic Buffer Management
- */
-
-#define DRM_MAP_HASH_OFFSET 0x10000000
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-static inline int drm_legacy_create_map_hash(struct drm_device *dev)
-{
- return drm_ht_create(&dev->map_hash, 12);
-}
-
-static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
-{
- drm_ht_remove(&dev->map_hash);
-}
-#else
-static inline int drm_legacy_create_map_hash(struct drm_device *dev)
-{
- return 0;
-}
-
-static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
-#endif
-
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
-
-int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
-#endif
-
-int __drm_legacy_infobufs(struct drm_device *, void *, int *,
- int (*)(void *, int, struct drm_buf_entry *));
-int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
- void __user **,
- int (*)(void *, int, unsigned long, struct drm_buf *),
- struct drm_file *);
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_master_rmmaps(struct drm_device *dev,
- struct drm_master *master);
-void drm_legacy_rmmaps(struct drm_device *dev);
-#else
-static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
- struct drm_master *master) {}
-static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
-#endif
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_vma_flush(struct drm_device *d);
-#else
-static inline void drm_legacy_vma_flush(struct drm_device *d)
-{
- /* do nothing */
-}
-#endif
-
-/*
- * AGP Support
- */
-
-struct drm_agp_mem {
- unsigned long handle;
- struct agp_memory *memory;
- unsigned long bound;
- int pages;
- struct list_head head;
-};
-
-/* drm_agpsupport.c */
-#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
-void drm_legacy_agp_clear(struct drm_device *dev);
-
-int drm_legacy_agp_acquire_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);
-int drm_legacy_agp_enable_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);
-int drm_legacy_agp_alloc_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);
-int drm_legacy_agp_unbind_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);
-#else
-static inline void drm_legacy_agp_clear(struct drm_device *dev) {}
-#endif
-
-/* drm_lock.c */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
-int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
-void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
-#else
-static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
-#endif
-
-/* DMA support */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int drm_legacy_dma_setup(struct drm_device *dev);
-void drm_legacy_dma_takedown(struct drm_device *dev);
-#else
-static inline int drm_legacy_dma_setup(struct drm_device *dev)
-{
- return 0;
-}
-#endif
-
-void drm_legacy_free_buffer(struct drm_device *dev,
- struct drm_buf * buf);
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_reclaim_buffers(struct drm_device *dev,
- struct drm_file *filp);
-#else
-static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
- struct drm_file *filp) {}
-#endif
-
-/* Scatter Gather Support */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_sg_cleanup(struct drm_device *dev);
-int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int drm_legacy_sg_free(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-#endif
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_init_members(struct drm_device *dev);
-void drm_legacy_destroy_members(struct drm_device *dev);
-void drm_legacy_dev_reinit(struct drm_device *dev);
-int drm_legacy_setup(struct drm_device * dev);
-#else
-static inline void drm_legacy_init_members(struct drm_device *dev) {}
-static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
-static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
-static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
-#endif
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
-#else
-static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
-#endif
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_master_legacy_init(struct drm_master *master);
-#else
-static inline void drm_master_legacy_init(struct drm_master *master) {}
-#endif
-
-/* drm_pci.c */
-#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
-int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv);
-void drm_legacy_pci_agp_destroy(struct drm_device *dev);
-#else
-static inline int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- return -EINVAL;
-}
-
-static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {}
-#endif
-
-#endif /* __DRM_LEGACY_H__ */
diff --git a/drivers/gpu/drm/drm_legacy_misc.c b/drivers/gpu/drm/drm_legacy_misc.c
deleted file mode 100644
index d4c5434062d7c..0000000000000
--- a/drivers/gpu/drm/drm_legacy_misc.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * \file drm_legacy_misc.c
- * Misc legacy support functions.
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <drm/drm_device.h>
-#include <drm/drm_drv.h>
-#include <drm/drm_print.h>
-
-#include "drm_internal.h"
-#include "drm_legacy.h"
-
-void drm_legacy_init_members(struct drm_device *dev)
-{
- INIT_LIST_HEAD(&dev->ctxlist);
- INIT_LIST_HEAD(&dev->vmalist);
- INIT_LIST_HEAD(&dev->maplist);
- spin_lock_init(&dev->buf_lock);
- mutex_init(&dev->ctxlist_mutex);
-}
-
-void drm_legacy_destroy_members(struct drm_device *dev)
-{
- mutex_destroy(&dev->ctxlist_mutex);
-}
-
-int drm_legacy_setup(struct drm_device * dev)
-{
- int ret;
-
- if (dev->driver->firstopen &&
- drm_core_check_feature(dev, DRIVER_LEGACY)) {
- ret = dev->driver->firstopen(dev);
- if (ret != 0)
- return ret;
- }
-
- ret = drm_legacy_dma_setup(dev);
- if (ret < 0)
- return ret;
-
-
- DRM_DEBUG("\n");
- return 0;
-}
-
-void drm_legacy_dev_reinit(struct drm_device *dev)
-{
- if (dev->irq_enabled)
- drm_legacy_irq_uninstall(dev);
-
- mutex_lock(&dev->struct_mutex);
-
- drm_legacy_agp_clear(dev);
-
- drm_legacy_sg_cleanup(dev);
- drm_legacy_vma_flush(dev);
- drm_legacy_dma_takedown(dev);
-
- mutex_unlock(&dev->struct_mutex);
-
- dev->sigdata.lock = NULL;
-
- dev->context_flag = 0;
- dev->last_context = 0;
- dev->if_version = 0;
-
- DRM_DEBUG("lastclose completed\n");
-}
-
-void drm_master_legacy_init(struct drm_master *master)
-{
- spin_lock_init(&master->lock.spinlock);
- init_waitqueue_head(&master->lock.lock_queue);
-}
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
deleted file mode 100644
index 1efbd5389d893..0000000000000
--- a/drivers/gpu/drm/drm_lock.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * \file drm_lock.c
- * IOCTLs for locking
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/export.h>
-#include <linux/sched/signal.h>
-
-#include <drm/drm.h>
-#include <drm/drm_drv.h>
-#include <drm/drm_file.h>
-#include <drm/drm_print.h>
-
-#include "drm_internal.h"
-#include "drm_legacy.h"
-
-static int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
-
-/*
- * Take the heavyweight lock.
- *
- * \param lock lock pointer.
- * \param context locking context.
- * \return one if the lock is held, or zero otherwise.
- *
- * Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction.
- */
-static
-int drm_lock_take(struct drm_lock_data *lock_data,
- unsigned int context)
-{
- unsigned int old, new, prev;
- volatile unsigned int *lock = &lock_data->hw_lock->lock;
-
- spin_lock_bh(&lock_data->spinlock);
- do {
- old = *lock;
- if (old & _DRM_LOCK_HELD)
- new = old | _DRM_LOCK_CONT;
- else {
- new = context | _DRM_LOCK_HELD |
- ((lock_data->user_waiters + lock_data->kernel_waiters > 1) ?
- _DRM_LOCK_CONT : 0);
- }
- prev = cmpxchg(lock, old, new);
- } while (prev != old);
- spin_unlock_bh(&lock_data->spinlock);
-
- if (_DRM_LOCKING_CONTEXT(old) == context) {
- if (old & _DRM_LOCK_HELD) {
- if (context != DRM_KERNEL_CONTEXT) {
- DRM_ERROR("%d holds heavyweight lock\n",
- context);
- }
- return 0;
- }
- }
-
- if ((_DRM_LOCKING_CONTEXT(new)) == context && (new & _DRM_LOCK_HELD)) {
- /* Have lock */
- return 1;
- }
- return 0;
-}
-
-/*
- * This takes a lock forcibly and hands it to context. Should ONLY be used
- * inside *_unlock to give lock to kernel before calling *_dma_schedule.
- *
- * \param dev DRM device.
- * \param lock lock pointer.
- * \param context locking context.
- * \return always one.
- *
- * Resets the lock file pointer.
- * Marks the lock as held by the given context, via the \p cmpxchg instruction.
- */
-static int drm_lock_transfer(struct drm_lock_data *lock_data,
- unsigned int context)
-{
- unsigned int old, new, prev;
- volatile unsigned int *lock = &lock_data->hw_lock->lock;
-
- lock_data->file_priv = NULL;
- do {
- old = *lock;
- new = context | _DRM_LOCK_HELD;
- prev = cmpxchg(lock, old, new);
- } while (prev != old);
- return 1;
-}
-
-static int drm_legacy_lock_free(struct drm_lock_data *lock_data,
- unsigned int context)
-{
- unsigned int old, new, prev;
- volatile unsigned int *lock = &lock_data->hw_lock->lock;
-
- spin_lock_bh(&lock_data->spinlock);
- if (lock_data->kernel_waiters != 0) {
- drm_lock_transfer(lock_data, 0);
- lock_data->idle_has_lock = 1;
- spin_unlock_bh(&lock_data->spinlock);
- return 1;
- }
- spin_unlock_bh(&lock_data->spinlock);
-
- do {
- old = *lock;
- new = _DRM_LOCKING_CONTEXT(old);
- prev = cmpxchg(lock, old, new);
- } while (prev != old);
-
- if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) {
- DRM_ERROR("%d freed heavyweight lock held by %d\n",
- context, _DRM_LOCKING_CONTEXT(old));
- return 1;
- }
- wake_up_interruptible(&lock_data->lock_queue);
- return 0;
-}
-
-/*
- * Lock ioctl.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument, pointing to a drm_lock structure.
- * \return zero on success or negative number on failure.
- *
- * Add the current task to the lock wait queue, and attempt to take to lock.
- */
-int drm_legacy_lock(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- DECLARE_WAITQUEUE(entry, current);
- struct drm_lock *lock = data;
- struct drm_master *master = file_priv->master;
- int ret = 0;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- ++file_priv->lock_count;
-
- if (lock->context == DRM_KERNEL_CONTEXT) {
- DRM_ERROR("Process %d using kernel context %d\n",
- task_pid_nr(current), lock->context);
- return -EINVAL;
- }
-
- DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
- lock->context, task_pid_nr(current),
- master->lock.hw_lock ? master->lock.hw_lock->lock : -1,
- lock->flags);
-
- add_wait_queue(&master->lock.lock_queue, &entry);
- spin_lock_bh(&master->lock.spinlock);
- master->lock.user_waiters++;
- spin_unlock_bh(&master->lock.spinlock);
-
- for (;;) {
- __set_current_state(TASK_INTERRUPTIBLE);
- if (!master->lock.hw_lock) {
- /* Device has been unregistered */
- send_sig(SIGTERM, current, 0);
- ret = -EINTR;
- break;
- }
- if (drm_lock_take(&master->lock, lock->context)) {
- master->lock.file_priv = file_priv;
- master->lock.lock_time = jiffies;
- break; /* Got lock */
- }
-
- /* Contention */
- mutex_unlock(&drm_global_mutex);
- schedule();
- mutex_lock(&drm_global_mutex);
- if (signal_pending(current)) {
- ret = -EINTR;
- break;
- }
- }
- spin_lock_bh(&master->lock.spinlock);
- master->lock.user_waiters--;
- spin_unlock_bh(&master->lock.spinlock);
- __set_current_state(TASK_RUNNING);
- remove_wait_queue(&master->lock.lock_queue, &entry);
-
- DRM_DEBUG("%d %s\n", lock->context,
- ret ? "interrupted" : "has lock");
- if (ret) return ret;
-
- /* don't set the block all signals on the master process for now
- * really probably not the correct answer but lets us debug xkb
- * xserver for now */
- if (!drm_is_current_master(file_priv)) {
- dev->sigdata.context = lock->context;
- dev->sigdata.lock = master->lock.hw_lock;
- }
-
- if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT))
- {
- if (dev->driver->dma_quiescent(dev)) {
- DRM_DEBUG("%d waiting for DMA quiescent\n",
- lock->context);
- return -EBUSY;
- }
- }
-
- return 0;
-}
-
-/*
- * Unlock ioctl.
- *
- * \param inode device inode.
- * \param file_priv DRM file private.
- * \param cmd command.
- * \param arg user argument, pointing to a drm_lock structure.
- * \return zero on success or negative number on failure.
- *
- * Transfer and free the lock.
- */
-int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
-{
- struct drm_lock *lock = data;
- struct drm_master *master = file_priv->master;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (lock->context == DRM_KERNEL_CONTEXT) {
- DRM_ERROR("Process %d using kernel context %d\n",
- task_pid_nr(current), lock->context);
- return -EINVAL;
- }
-
- if (drm_legacy_lock_free(&master->lock, lock->context)) {
- /* FIXME: Should really bail out here. */
- }
-
- return 0;
-}
-
-/*
- * This function returns immediately and takes the hw lock
- * with the kernel context if it is free, otherwise it gets the highest priority when and if
- * it is eventually released.
- *
- * This guarantees that the kernel will _eventually_ have the lock _unless_ it is held
- * by a blocked process. (In the latter case an explicit wait for the hardware lock would cause
- * a deadlock, which is why the "idlelock" was invented).
- *
- * This should be sufficient to wait for GPU idle without
- * having to worry about starvation.
- */
-void drm_legacy_idlelock_take(struct drm_lock_data *lock_data)
-{
- int ret;
-
- spin_lock_bh(&lock_data->spinlock);
- lock_data->kernel_waiters++;
- if (!lock_data->idle_has_lock) {
-
- spin_unlock_bh(&lock_data->spinlock);
- ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT);
- spin_lock_bh(&lock_data->spinlock);
-
- if (ret == 1)
- lock_data->idle_has_lock = 1;
- }
- spin_unlock_bh(&lock_data->spinlock);
-}
-EXPORT_SYMBOL(drm_legacy_idlelock_take);
-
-void drm_legacy_idlelock_release(struct drm_lock_data *lock_data)
-{
- unsigned int old, prev;
- volatile unsigned int *lock = &lock_data->hw_lock->lock;
-
- spin_lock_bh(&lock_data->spinlock);
- if (--lock_data->kernel_waiters == 0) {
- if (lock_data->idle_has_lock) {
- do {
- old = *lock;
- prev = cmpxchg(lock, old, DRM_KERNEL_CONTEXT);
- } while (prev != old);
- wake_up_interruptible(&lock_data->lock_queue);
- lock_data->idle_has_lock = 0;
- }
- }
- spin_unlock_bh(&lock_data->spinlock);
-}
-EXPORT_SYMBOL(drm_legacy_idlelock_release);
-
-static int drm_legacy_i_have_hw_lock(struct drm_device *dev,
- struct drm_file *file_priv)
-{
- struct drm_master *master = file_priv->master;
-
- return (file_priv->lock_count && master->lock.hw_lock &&
- _DRM_LOCK_IS_HELD(master->lock.hw_lock->lock) &&
- master->lock.file_priv == file_priv);
-}
-
-void drm_legacy_lock_release(struct drm_device *dev, struct file *filp)
-{
- struct drm_file *file_priv = filp->private_data;
-
- /* if the master has gone away we can't do anything with the lock */
- if (!dev->master)
- return;
-
- if (drm_legacy_i_have_hw_lock(dev, file_priv)) {
- DRM_DEBUG("File %p released, freeing lock for context %d\n",
- filp, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
- drm_legacy_lock_free(&file_priv->master->lock,
- _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
- }
-}
-
-void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master)
-{
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return;
-
- /*
- * Since the master is disappearing, so is the
- * possibility to lock.
- */
- mutex_lock(&dev->struct_mutex);
- if (master->lock.hw_lock) {
- if (dev->sigdata.lock == master->lock.hw_lock)
- dev->sigdata.lock = NULL;
- master->lock.hw_lock = NULL;
- master->lock.file_priv = NULL;
- wake_up_interruptible_all(&master->lock.lock_queue);
- }
- mutex_unlock(&dev->struct_mutex);
-}
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
deleted file mode 100644
index d2e1dccd8113e..0000000000000
--- a/drivers/gpu/drm/drm_memory.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * \file drm_memory.c
- * Memory management wrappers for DRM
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/export.h>
-#include <linux/highmem.h>
-#include <linux/pci.h>
-#include <linux/vmalloc.h>
-
-#include <drm/drm_cache.h>
-#include <drm/drm_device.h>
-
-#include "drm_legacy.h"
-
-#if IS_ENABLED(CONFIG_AGP)
-
-#ifdef HAVE_PAGE_AGP
-# include <asm/agp.h>
-#else
-# ifdef __powerpc__
-# define PAGE_AGP pgprot_noncached_wc(PAGE_KERNEL)
-# else
-# define PAGE_AGP PAGE_KERNEL
-# endif
-#endif
-
-static void *agp_remap(unsigned long offset, unsigned long size,
- struct drm_device *dev)
-{
- unsigned long i, num_pages =
- PAGE_ALIGN(size) / PAGE_SIZE;
- struct drm_agp_mem *agpmem;
- struct page **page_map;
- struct page **phys_page_map;
- void *addr;
-
- size = PAGE_ALIGN(size);
-
-#ifdef __alpha__
- offset -= dev->hose->mem_space->start;
-#endif
-
- list_for_each_entry(agpmem, &dev->agp->memory, head)
- if (agpmem->bound <= offset
- && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
- (offset + size))
- break;
- if (&agpmem->head == &dev->agp->memory)
- return NULL;
-
- /*
- * OK, we're mapping AGP space on a chipset/platform on which memory accesses by
- * the CPU do not get remapped by the GART. We fix this by using the kernel's
- * page-table instead (that's probably faster anyhow...).
- */
- /* note: use vmalloc() because num_pages could be large... */
- page_map = vmalloc(array_size(num_pages, sizeof(struct page *)));
- if (!page_map)
- return NULL;
-
- phys_page_map = (agpmem->memory->pages + (offset - agpmem->bound) / PAGE_SIZE);
- for (i = 0; i < num_pages; ++i)
- page_map[i] = phys_page_map[i];
- addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP);
- vfree(page_map);
-
- return addr;
-}
-
-#else /* CONFIG_AGP */
-static inline void *agp_remap(unsigned long offset, unsigned long size,
- struct drm_device *dev)
-{
- return NULL;
-}
-
-#endif /* CONFIG_AGP */
-
-void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev)
-{
- if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
- map->handle = agp_remap(map->offset, map->size, dev);
- else
- map->handle = ioremap(map->offset, map->size);
-}
-EXPORT_SYMBOL(drm_legacy_ioremap);
-
-void drm_legacy_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
-{
- if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
- map->handle = agp_remap(map->offset, map->size, dev);
- else
- map->handle = ioremap_wc(map->offset, map->size);
-}
-EXPORT_SYMBOL(drm_legacy_ioremap_wc);
-
-void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
-{
- if (!map->handle || !map->size)
- return;
-
- if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
- vunmap(map->handle);
- else
- iounmap(map->handle);
-}
-EXPORT_SYMBOL(drm_legacy_ioremapfree);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 67907dd427214..c585f1e8803ec 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -35,13 +35,6 @@
#include <drm/drm_print.h>
#include "drm_internal.h"
-#include "drm_legacy.h"
-
-#ifdef CONFIG_DRM_LEGACY
-/* List of devices hanging off drivers with stealth attach. */
-static LIST_HEAD(legacy_dev_list);
-static DEFINE_MUTEX(legacy_dev_list_lock);
-#endif
static int drm_get_pci_domain(struct drm_device *dev)
{
@@ -72,199 +65,3 @@ int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
master->unique_len = strlen(master->unique);
return 0;
}
-
-#ifdef CONFIG_DRM_LEGACY
-
-static int drm_legacy_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
-{
- struct pci_dev *pdev = to_pci_dev(dev->dev);
-
- if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
- (p->busnum & 0xff) != pdev->bus->number ||
- p->devnum != PCI_SLOT(pdev->devfn) || p->funcnum != PCI_FUNC(pdev->devfn))
- return -EINVAL;
-
- p->irq = pdev->irq;
-
- DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum,
- p->irq);
- return 0;
-}
-
-/**
- * drm_legacy_irq_by_busid - Get interrupt from bus ID
- * @dev: DRM device
- * @data: IOCTL parameter pointing to a drm_irq_busid structure
- * @file_priv: DRM file private.
- *
- * Finds the PCI device with the specified bus id and gets its IRQ number.
- * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
- * to that of the device that this DRM instance attached to.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_irq_busid *p = data;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- /* UMS was only ever support on PCI devices. */
- if (WARN_ON(!dev_is_pci(dev->dev)))
- return -EINVAL;
-
- if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
- return -EOPNOTSUPP;
-
- return drm_legacy_pci_irq_by_busid(dev, p);
-}
-
-void drm_legacy_pci_agp_destroy(struct drm_device *dev)
-{
- if (dev->agp) {
- arch_phys_wc_del(dev->agp->agp_mtrr);
- drm_legacy_agp_clear(dev);
- kfree(dev->agp);
- dev->agp = NULL;
- }
-}
-
-static void drm_legacy_pci_agp_init(struct drm_device *dev)
-{
- if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
- if (pci_find_capability(to_pci_dev(dev->dev), PCI_CAP_ID_AGP))
- dev->agp = drm_legacy_agp_init(dev);
- if (dev->agp) {
- dev->agp->agp_mtrr = arch_phys_wc_add(
- dev->agp->agp_info.aper_base,
- dev->agp->agp_info.aper_size *
- 1024 * 1024);
- }
- }
-}
-
-static int drm_legacy_get_pci_dev(struct pci_dev *pdev,
- const struct pci_device_id *ent,
- const struct drm_driver *driver)
-{
- struct drm_device *dev;
- int ret;
-
- DRM_DEBUG("\n");
-
- dev = drm_dev_alloc(driver, &pdev->dev);
- if (IS_ERR(dev))
- return PTR_ERR(dev);
-
- ret = pci_enable_device(pdev);
- if (ret)
- goto err_free;
-
-#ifdef __alpha__
- dev->hose = pdev->sysdata;
-#endif
-
- drm_legacy_pci_agp_init(dev);
-
- ret = drm_dev_register(dev, ent->driver_data);
- if (ret)
- goto err_agp;
-
- if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
- mutex_lock(&legacy_dev_list_lock);
- list_add_tail(&dev->legacy_dev_list, &legacy_dev_list);
- mutex_unlock(&legacy_dev_list_lock);
- }
-
- return 0;
-
-err_agp:
- drm_legacy_pci_agp_destroy(dev);
- pci_disable_device(pdev);
-err_free:
- drm_dev_put(dev);
- return ret;
-}
-
-/**
- * drm_legacy_pci_init - shadow-attach a legacy DRM PCI driver
- * @driver: DRM device driver
- * @pdriver: PCI device driver
- *
- * This is only used by legacy dri1 drivers and deprecated.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-int drm_legacy_pci_init(const struct drm_driver *driver,
- struct pci_driver *pdriver)
-{
- struct pci_dev *pdev = NULL;
- const struct pci_device_id *pid;
- int i;
-
- DRM_DEBUG("\n");
-
- if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
- return -EINVAL;
-
- /* If not using KMS, fall back to stealth mode manual scanning. */
- for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
- pid = &pdriver->id_table[i];
-
- /* Loop around setting up a DRM device for each PCI device
- * matching our ID and device class. If we had the internal
- * function that pci_get_subsys and pci_get_class used, we'd
- * be able to just pass pid in instead of doing a two-stage
- * thing.
- */
- pdev = NULL;
- while ((pdev =
- pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
- pid->subdevice, pdev)) != NULL) {
- if ((pdev->class & pid->class_mask) != pid->class)
- continue;
-
- /* stealth mode requires a manual probe */
- pci_dev_get(pdev);
- drm_legacy_get_pci_dev(pdev, pid, driver);
- }
- }
- return 0;
-}
-EXPORT_SYMBOL(drm_legacy_pci_init);
-
-/**
- * drm_legacy_pci_exit - unregister shadow-attach legacy DRM driver
- * @driver: DRM device driver
- * @pdriver: PCI device driver
- *
- * Unregister a DRM driver shadow-attached through drm_legacy_pci_init(). This
- * is deprecated and only used by dri1 drivers.
- */
-void drm_legacy_pci_exit(const struct drm_driver *driver,
- struct pci_driver *pdriver)
-{
- struct drm_device *dev, *tmp;
-
- DRM_DEBUG("\n");
-
- if (!(driver->driver_features & DRIVER_LEGACY)) {
- WARN_ON(1);
- } else {
- mutex_lock(&legacy_dev_list_lock);
- list_for_each_entry_safe(dev, tmp, &legacy_dev_list,
- legacy_dev_list) {
- if (dev->driver == driver) {
- list_del(&dev->legacy_dev_list);
- drm_put_dev(dev);
- }
- }
- mutex_unlock(&legacy_dev_list_lock);
- }
- DRM_INFO("Module unloaded\n");
-}
-EXPORT_SYMBOL(drm_legacy_pci_exit);
-
-#endif
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
deleted file mode 100644
index f4e6184d18772..0000000000000
--- a/drivers/gpu/drm/drm_scatter.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * \file drm_scatter.c
- * IOCTLs to manage scatter/gather memory
- *
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Mon Dec 18 23:20:54 2000 by gareth@valinux.com
- *
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-
-#include <drm/drm.h>
-#include <drm/drm_drv.h>
-#include <drm/drm_print.h>
-
-#include "drm_legacy.h"
-
-#define DEBUG_SCATTER 0
-
-static void drm_sg_cleanup(struct drm_sg_mem * entry)
-{
- struct page *page;
- int i;
-
- for (i = 0; i < entry->pages; i++) {
- page = entry->pagelist[i];
- if (page)
- ClearPageReserved(page);
- }
-
- vfree(entry->virtual);
-
- kfree(entry->busaddr);
- kfree(entry->pagelist);
- kfree(entry);
-}
-
-void drm_legacy_sg_cleanup(struct drm_device *dev)
-{
- if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
- drm_core_check_feature(dev, DRIVER_LEGACY)) {
- drm_sg_cleanup(dev->sg);
- dev->sg = NULL;
- }
-}
-#ifdef _LP64
-# define ScatterHandle(x) (unsigned int)((x >> 32) + (x & ((1L << 32) - 1)))
-#else
-# define ScatterHandle(x) (unsigned int)(x)
-#endif
-
-int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_scatter_gather *request = data;
- struct drm_sg_mem *entry;
- unsigned long pages, i, j;
-
- DRM_DEBUG("\n");
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_SG))
- return -EOPNOTSUPP;
-
- if (request->size > SIZE_MAX - PAGE_SIZE)
- return -EINVAL;
-
- if (dev->sg)
- return -EINVAL;
-
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
- if (!entry)
- return -ENOMEM;
-
- pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
- DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages);
-
- entry->pages = pages;
- entry->pagelist = kcalloc(pages, sizeof(*entry->pagelist), GFP_KERNEL);
- if (!entry->pagelist) {
- kfree(entry);
- return -ENOMEM;
- }
-
- entry->busaddr = kcalloc(pages, sizeof(*entry->busaddr), GFP_KERNEL);
- if (!entry->busaddr) {
- kfree(entry->pagelist);
- kfree(entry);
- return -ENOMEM;
- }
-
- entry->virtual = vmalloc_32(pages << PAGE_SHIFT);
- if (!entry->virtual) {
- kfree(entry->busaddr);
- kfree(entry->pagelist);
- kfree(entry);
- return -ENOMEM;
- }
-
- /* This also forces the mapping of COW pages, so our page list
- * will be valid. Please don't remove it...
- */
- memset(entry->virtual, 0, pages << PAGE_SHIFT);
-
- entry->handle = ScatterHandle((unsigned long)entry->virtual);
-
- DRM_DEBUG("handle = %08lx\n", entry->handle);
- DRM_DEBUG("virtual = %p\n", entry->virtual);
-
- for (i = (unsigned long)entry->virtual, j = 0; j < pages;
- i += PAGE_SIZE, j++) {
- entry->pagelist[j] = vmalloc_to_page((void *)i);
- if (!entry->pagelist[j])
- goto failed;
- SetPageReserved(entry->pagelist[j]);
- }
-
- request->handle = entry->handle;
-
- dev->sg = entry;
-
-#if DEBUG_SCATTER
- /* Verify that each page points to its virtual address, and vice
- * versa.
- */
- {
- int error = 0;
-
- for (i = 0; i < pages; i++) {
- unsigned long *tmp;
-
- tmp = page_address(entry->pagelist[i]);
- for (j = 0;
- j < PAGE_SIZE / sizeof(unsigned long);
- j++, tmp++) {
- *tmp = 0xcafebabe;
- }
- tmp = (unsigned long *)((u8 *) entry->virtual +
- (PAGE_SIZE * i));
- for (j = 0;
- j < PAGE_SIZE / sizeof(unsigned long);
- j++, tmp++) {
- if (*tmp != 0xcafebabe && error == 0) {
- error = 1;
- DRM_ERROR("Scatter allocation error, "
- "pagelist does not match "
- "virtual mapping\n");
- }
- }
- tmp = page_address(entry->pagelist[i]);
- for (j = 0;
- j < PAGE_SIZE / sizeof(unsigned long);
- j++, tmp++) {
- *tmp = 0;
- }
- }
- if (error == 0)
- DRM_ERROR("Scatter allocation matches pagelist\n");
- }
-#endif
-
- return 0;
-
- failed:
- drm_sg_cleanup(entry);
- return -ENOMEM;
-}
-
-int drm_legacy_sg_free(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_scatter_gather *request = data;
- struct drm_sg_mem *entry;
-
- if (!drm_core_check_feature(dev, DRIVER_LEGACY))
- return -EOPNOTSUPP;
-
- if (!drm_core_check_feature(dev, DRIVER_SG))
- return -EOPNOTSUPP;
-
- entry = dev->sg;
- dev->sg = NULL;
-
- if (!entry || entry->handle != request->handle)
- return -EINVAL;
-
- DRM_DEBUG("virtual = %p\n", entry->virtual);
-
- drm_sg_cleanup(entry);
-
- return 0;
-}
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
deleted file mode 100644
index 87c9fe55dec76..0000000000000
--- a/drivers/gpu/drm/drm_vm.c
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- * \file drm_vm.c
- * Memory mapping for DRM
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/export.h>
-#include <linux/pci.h>
-#include <linux/seq_file.h>
-#include <linux/vmalloc.h>
-#include <linux/pgtable.h>
-
-#if defined(__ia64__)
-#include <linux/efi.h>
-#include <linux/slab.h>
-#endif
-#include <linux/mem_encrypt.h>
-
-#include <drm/drm_device.h>
-#include <drm/drm_drv.h>
-#include <drm/drm_file.h>
-#include <drm/drm_framebuffer.h>
-#include <drm/drm_print.h>
-
-#include "drm_internal.h"
-#include "drm_legacy.h"
-
-struct drm_vma_entry {
- struct list_head head;
- struct vm_area_struct *vma;
- pid_t pid;
-};
-
-static void drm_vm_open(struct vm_area_struct *vma);
-static void drm_vm_close(struct vm_area_struct *vma);
-
-static pgprot_t drm_io_prot(struct drm_local_map *map,
- struct vm_area_struct *vma)
-{
- pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
-
-#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
- defined(__mips__) || defined(__loongarch__)
- if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
- tmp = pgprot_noncached(tmp);
- else
- tmp = pgprot_writecombine(tmp);
-#elif defined(__ia64__)
- if (efi_range_is_wc(vma->vm_start, vma->vm_end -
- vma->vm_start))
- tmp = pgprot_writecombine(tmp);
- else
- tmp = pgprot_noncached(tmp);
-#elif defined(__sparc__) || defined(__arm__)
- tmp = pgprot_noncached(tmp);
-#endif
- return tmp;
-}
-
-static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
-{
- pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
-
-#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
- tmp = pgprot_noncached_wc(tmp);
-#endif
- return tmp;
-}
-
-/*
- * \c fault method for AGP virtual memory.
- *
- * \param vma virtual memory area.
- * \param address access address.
- * \return pointer to the page structure.
- *
- * Find the right map and if it's AGP memory find the real physical page to
- * map, get the page, increment the use count and return it.
- */
-#if IS_ENABLED(CONFIG_AGP)
-static vm_fault_t drm_vm_fault(struct vm_fault *vmf)
-{
- struct vm_area_struct *vma = vmf->vma;
- struct drm_file *priv = vma->vm_file->private_data;
- struct drm_device *dev = priv->minor->dev;
- struct drm_local_map *map = NULL;
- struct drm_map_list *r_list;
- struct drm_hash_item *hash;
-
- /*
- * Find the right map
- */
- if (!dev->agp)
- goto vm_fault_error;
-
- if (!dev->agp || !dev->agp->cant_use_aperture)
- goto vm_fault_error;
-
- if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash))
- goto vm_fault_error;
-
- r_list = drm_hash_entry(hash, struct drm_map_list, hash);
- map = r_list->map;
-
- if (map && map->type == _DRM_AGP) {
- /*
- * Using vm_pgoff as a selector forces us to use this unusual
- * addressing scheme.
- */
- resource_size_t offset = vmf->address - vma->vm_start;
- resource_size_t baddr = map->offset + offset;
- struct drm_agp_mem *agpmem;
- struct page *page;
-
-#ifdef __alpha__
- /*
- * Adjust to a bus-relative address
- */
- baddr -= dev->hose->mem_space->start;
-#endif
-
- /*
- * It's AGP memory - find the real physical page to map
- */
- list_for_each_entry(agpmem, &dev->agp->memory, head) {
- if (agpmem->bound <= baddr &&
- agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
- break;
- }
-
- if (&agpmem->head == &dev->agp->memory)
- goto vm_fault_error;
-
- /*
- * Get the page, inc the use count, and return it
- */
- offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
- page = agpmem->memory->pages[offset];
- get_page(page);
- vmf->page = page;
-
- DRM_DEBUG
- ("baddr = 0x%llx page = 0x%p, offset = 0x%llx, count=%d\n",
- (unsigned long long)baddr,
- agpmem->memory->pages[offset],
- (unsigned long long)offset,
- page_count(page));
- return 0;
- }
-vm_fault_error:
- return VM_FAULT_SIGBUS; /* Disallow mremap */
-}
-#else
-static vm_fault_t drm_vm_fault(struct vm_fault *vmf)
-{
- return VM_FAULT_SIGBUS;
-}
-#endif
-
-/*
- * \c nopage method for shared virtual memory.
- *
- * \param vma virtual memory area.
- * \param address access address.
- * \return pointer to the page structure.
- *
- * Get the mapping, find the real physical page to map, get the page, and
- * return it.
- */
-static vm_fault_t drm_vm_shm_fault(struct vm_fault *vmf)
-{
- struct vm_area_struct *vma = vmf->vma;
- struct drm_local_map *map = vma->vm_private_data;
- unsigned long offset;
- unsigned long i;
- struct page *page;
-
- if (!map)
- return VM_FAULT_SIGBUS; /* Nothing allocated */
-
- offset = vmf->address - vma->vm_start;
- i = (unsigned long)map->handle + offset;
- page = vmalloc_to_page((void *)i);
- if (!page)
- return VM_FAULT_SIGBUS;
- get_page(page);
- vmf->page = page;
-
- DRM_DEBUG("shm_fault 0x%lx\n", offset);
- return 0;
-}
-
-/*
- * \c close method for shared virtual memory.
- *
- * \param vma virtual memory area.
- *
- * Deletes map information if we are the last
- * person to close a mapping and it's not in the global maplist.
- */
-static void drm_vm_shm_close(struct vm_area_struct *vma)
-{
- struct drm_file *priv = vma->vm_file->private_data;
- struct drm_device *dev = priv->minor->dev;
- struct drm_vma_entry *pt, *temp;
- struct drm_local_map *map;
- struct drm_map_list *r_list;
- int found_maps = 0;
-
- DRM_DEBUG("0x%08lx,0x%08lx\n",
- vma->vm_start, vma->vm_end - vma->vm_start);
-
- map = vma->vm_private_data;
-
- mutex_lock(&dev->struct_mutex);
- list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
- if (pt->vma->vm_private_data == map)
- found_maps++;
- if (pt->vma == vma) {
- list_del(&pt->head);
- kfree(pt);
- }
- }
-
- /* We were the only map that was found */
- if (found_maps == 1 && map->flags & _DRM_REMOVABLE) {
- /* Check to see if we are in the maplist, if we are not, then
- * we delete this mappings information.
- */
- found_maps = 0;
- list_for_each_entry(r_list, &dev->maplist, head) {
- if (r_list->map == map)
- found_maps++;
- }
-
- if (!found_maps) {
- switch (map->type) {
- case _DRM_REGISTERS:
- case _DRM_FRAME_BUFFER:
- arch_phys_wc_del(map->mtrr);
- iounmap(map->handle);
- break;
- case _DRM_SHM:
- vfree(map->handle);
- break;
- case _DRM_AGP:
- case _DRM_SCATTER_GATHER:
- break;
- case _DRM_CONSISTENT:
- dma_free_coherent(dev->dev,
- map->size,
- map->handle,
- map->offset);
- break;
- }
- kfree(map);
- }
- }
- mutex_unlock(&dev->struct_mutex);
-}
-
-/*
- * \c fault method for DMA virtual memory.
- *
- * \param address access address.
- * \return pointer to the page structure.
- *
- * Determine the page number from the page offset and get it from drm_device_dma::pagelist.
- */
-static vm_fault_t drm_vm_dma_fault(struct vm_fault *vmf)
-{
- struct vm_area_struct *vma = vmf->vma;
- struct drm_file *priv = vma->vm_file->private_data;
- struct drm_device *dev = priv->minor->dev;
- struct drm_device_dma *dma = dev->dma;
- unsigned long offset;
- unsigned long page_nr;
- struct page *page;
-
- if (!dma)
- return VM_FAULT_SIGBUS; /* Error */
- if (!dma->pagelist)
- return VM_FAULT_SIGBUS; /* Nothing allocated */
-
- offset = vmf->address - vma->vm_start;
- /* vm_[pg]off[set] should be 0 */
- page_nr = offset >> PAGE_SHIFT; /* page_nr could just be vmf->pgoff */
- page = virt_to_page((void *)dma->pagelist[page_nr]);
-
- get_page(page);
- vmf->page = page;
-
- DRM_DEBUG("dma_fault 0x%lx (page %lu)\n", offset, page_nr);
- return 0;
-}
-
-/*
- * \c fault method for scatter-gather virtual memory.
- *
- * \param address access address.
- * \return pointer to the page structure.
- *
- * Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
- */
-static vm_fault_t drm_vm_sg_fault(struct vm_fault *vmf)
-{
- struct vm_area_struct *vma = vmf->vma;
- struct drm_local_map *map = vma->vm_private_data;
- struct drm_file *priv = vma->vm_file->private_data;
- struct drm_device *dev = priv->minor->dev;
- struct drm_sg_mem *entry = dev->sg;
- unsigned long offset;
- unsigned long map_offset;
- unsigned long page_offset;
- struct page *page;
-
- if (!entry)
- return VM_FAULT_SIGBUS; /* Error */
- if (!entry->pagelist)
- return VM_FAULT_SIGBUS; /* Nothing allocated */
-
- offset = vmf->address - vma->vm_start;
- map_offset = map->offset - (unsigned long)dev->sg->virtual;
- page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
- page = entry->pagelist[page_offset];
- get_page(page);
- vmf->page = page;
-
- return 0;
-}
-
-/** AGP virtual memory operations */
-static const struct vm_operations_struct drm_vm_ops = {
- .fault = drm_vm_fault,
- .open = drm_vm_open,
- .close = drm_vm_close,
-};
-
-/** Shared virtual memory operations */
-static const struct vm_operations_struct drm_vm_shm_ops = {
- .fault = drm_vm_shm_fault,
- .open = drm_vm_open,
- .close = drm_vm_shm_close,
-};
-
-/** DMA virtual memory operations */
-static const struct vm_operations_struct drm_vm_dma_ops = {
- .fault = drm_vm_dma_fault,
- .open = drm_vm_open,
- .close = drm_vm_close,
-};
-
-/** Scatter-gather virtual memory operations */
-static const struct vm_operations_struct drm_vm_sg_ops = {
- .fault = drm_vm_sg_fault,
- .open = drm_vm_open,
- .close = drm_vm_close,
-};
-
-static void drm_vm_open_locked(struct drm_device *dev,
- struct vm_area_struct *vma)
-{
- struct drm_vma_entry *vma_entry;
-
- DRM_DEBUG("0x%08lx,0x%08lx\n",
- vma->vm_start, vma->vm_end - vma->vm_start);
-
- vma_entry = kmalloc(sizeof(*vma_entry), GFP_KERNEL);
- if (vma_entry) {
- vma_entry->vma = vma;
- vma_entry->pid = current->pid;
- list_add(&vma_entry->head, &dev->vmalist);
- }
-}
-
-static void drm_vm_open(struct vm_area_struct *vma)
-{
- struct drm_file *priv = vma->vm_file->private_data;
- struct drm_device *dev = priv->minor->dev;
-
- mutex_lock(&dev->struct_mutex);
- drm_vm_open_locked(dev, vma);
- mutex_unlock(&dev->struct_mutex);
-}
-
-static void drm_vm_close_locked(struct drm_device *dev,
- struct vm_area_struct *vma)
-{
- struct drm_vma_entry *pt, *temp;
-
- DRM_DEBUG("0x%08lx,0x%08lx\n",
- vma->vm_start, vma->vm_end - vma->vm_start);
-
- list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
- if (pt->vma == vma) {
- list_del(&pt->head);
- kfree(pt);
- break;
- }
- }
-}
-
-/*
- * \c close method for all virtual memory types.
- *
- * \param vma virtual memory area.
- *
- * Search the \p vma private data entry in drm_device::vmalist, unlink it, and
- * free it.
- */
-static void drm_vm_close(struct vm_area_struct *vma)
-{
- struct drm_file *priv = vma->vm_file->private_data;
- struct drm_device *dev = priv->minor->dev;
-
- mutex_lock(&dev->struct_mutex);
- drm_vm_close_locked(dev, vma);
- mutex_unlock(&dev->struct_mutex);
-}
-
-/*
- * mmap DMA memory.
- *
- * \param file_priv DRM file private.
- * \param vma virtual memory area.
- * \return zero on success or a negative number on failure.
- *
- * Sets the virtual memory area operations structure to vm_dma_ops, the file
- * pointer, and calls vm_open().
- */
-static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
-{
- struct drm_file *priv = filp->private_data;
- struct drm_device *dev;
- struct drm_device_dma *dma;
- unsigned long length = vma->vm_end - vma->vm_start;
-
- dev = priv->minor->dev;
- dma = dev->dma;
- DRM_DEBUG("start = 0x%lx, end = 0x%lx, page offset = 0x%lx\n",
- vma->vm_start, vma->vm_end, vma->vm_pgoff);
-
- /* Length must match exact page count */
- if (!dma || (length >> PAGE_SHIFT) != dma->page_count) {
- return -EINVAL;
- }
-
- if (!capable(CAP_SYS_ADMIN) &&
- (dma->flags & _DRM_DMA_USE_PCI_RO)) {
- vm_flags_clear(vma, VM_WRITE | VM_MAYWRITE);
-#if defined(__i386__) || defined(__x86_64__)
- pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
-#else
- /* Ye gads this is ugly. With more thought
- we could move this up higher and use
- `protection_map' instead. */
- vma->vm_page_prot =
- __pgprot(pte_val
- (pte_wrprotect
- (__pte(pgprot_val(vma->vm_page_prot)))));
-#endif
- }
-
- vma->vm_ops = &drm_vm_dma_ops;
-
- vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
-
- drm_vm_open_locked(dev, vma);
- return 0;
-}
-
-static resource_size_t drm_core_get_reg_ofs(struct drm_device *dev)
-{
-#ifdef __alpha__
- return dev->hose->dense_mem_base;
-#else
- return 0;
-#endif
-}
-
-/*
- * mmap DMA memory.
- *
- * \param file_priv DRM file private.
- * \param vma virtual memory area.
- * \return zero on success or a negative number on failure.
- *
- * If the virtual memory area has no offset associated with it then it's a DMA
- * area, so calls mmap_dma(). Otherwise searches the map in drm_device::maplist,
- * checks that the restricted flag is not set, sets the virtual memory operations
- * according to the mapping type and remaps the pages. Finally sets the file
- * pointer and calls vm_open().
- */
-static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
-{
- struct drm_file *priv = filp->private_data;
- struct drm_device *dev = priv->minor->dev;
- struct drm_local_map *map = NULL;
- resource_size_t offset = 0;
- struct drm_hash_item *hash;
-
- DRM_DEBUG("start = 0x%lx, end = 0x%lx, page offset = 0x%lx\n",
- vma->vm_start, vma->vm_end, vma->vm_pgoff);
-
- if (!priv->authenticated)
- return -EACCES;
-
- /* We check for "dma". On Apple's UniNorth, it's valid to have
- * the AGP mapped at physical address 0
- * --BenH.
- */
- if (!vma->vm_pgoff
-#if IS_ENABLED(CONFIG_AGP)
- && (!dev->agp
- || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE)
-#endif
- )
- return drm_mmap_dma(filp, vma);
-
- if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash)) {
- DRM_ERROR("Could not find map\n");
- return -EINVAL;
- }
-
- map = drm_hash_entry(hash, struct drm_map_list, hash)->map;
- if (!map || ((map->flags & _DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN)))
- return -EPERM;
-
- /* Check for valid size. */
- if (map->size < vma->vm_end - vma->vm_start)
- return -EINVAL;
-
- if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) {
- vm_flags_clear(vma, VM_WRITE | VM_MAYWRITE);
-#if defined(__i386__) || defined(__x86_64__)
- pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
-#else
- /* Ye gads this is ugly. With more thought
- we could move this up higher and use
- `protection_map' instead. */
- vma->vm_page_prot =
- __pgprot(pte_val
- (pte_wrprotect
- (__pte(pgprot_val(vma->vm_page_prot)))));
-#endif
- }
-
- switch (map->type) {
-#if !defined(__arm__)
- case _DRM_AGP:
- if (dev->agp && dev->agp->cant_use_aperture) {
- /*
- * On some platforms we can't talk to bus dma address from the CPU, so for
- * memory of type DRM_AGP, we'll deal with sorting out the real physical
- * pages and mappings in fault()
- */
-#if defined(__powerpc__)
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-#endif
- vma->vm_ops = &drm_vm_ops;
- break;
- }
- fallthrough; /* to _DRM_FRAME_BUFFER... */
-#endif
- case _DRM_FRAME_BUFFER:
- case _DRM_REGISTERS:
- offset = drm_core_get_reg_ofs(dev);
- vma->vm_page_prot = drm_io_prot(map, vma);
- if (io_remap_pfn_range(vma, vma->vm_start,
- (map->offset + offset) >> PAGE_SHIFT,
- vma->vm_end - vma->vm_start,
- vma->vm_page_prot))
- return -EAGAIN;
- DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx,"
- " offset = 0x%llx\n",
- map->type,
- vma->vm_start, vma->vm_end, (unsigned long long)(map->offset + offset));
-
- vma->vm_ops = &drm_vm_ops;
- break;
- case _DRM_CONSISTENT:
- /* Consistent memory is really like shared memory. But
- * it's allocated in a different way, so avoid fault */
- if (remap_pfn_range(vma, vma->vm_start,
- page_to_pfn(virt_to_page(map->handle)),
- vma->vm_end - vma->vm_start, vma->vm_page_prot))
- return -EAGAIN;
- vma->vm_page_prot = drm_dma_prot(map->type, vma);
- fallthrough; /* to _DRM_SHM */
- case _DRM_SHM:
- vma->vm_ops = &drm_vm_shm_ops;
- vma->vm_private_data = (void *)map;
- break;
- case _DRM_SCATTER_GATHER:
- vma->vm_ops = &drm_vm_sg_ops;
- vma->vm_private_data = (void *)map;
- vma->vm_page_prot = drm_dma_prot(map->type, vma);
- break;
- default:
- return -EINVAL; /* This should never happen. */
- }
- vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
-
- drm_vm_open_locked(dev, vma);
- return 0;
-}
-
-int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma)
-{
- struct drm_file *priv = filp->private_data;
- struct drm_device *dev = priv->minor->dev;
- int ret;
-
- if (drm_dev_is_unplugged(dev))
- return -ENODEV;
-
- mutex_lock(&dev->struct_mutex);
- ret = drm_mmap_locked(filp, vma);
- mutex_unlock(&dev->struct_mutex);
-
- return ret;
-}
-EXPORT_SYMBOL(drm_legacy_mmap);
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-void drm_legacy_vma_flush(struct drm_device *dev)
-{
- struct drm_vma_entry *vma, *vma_temp;
-
- /* Clear vma list (only needed for legacy drivers) */
- list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
- list_del(&vma->head);
- kfree(vma);
- }
-}
-#endif
diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
index ba248ca8866f5..50131383ed814 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -33,24 +33,6 @@
#include <linux/wait.h>
struct drm_file;
-struct drm_hw_lock;
-
-/*
- * Legacy DRI1 locking data structure. Only here instead of in drm_legacy.h for
- * include ordering reasons.
- *
- * DO NOT USE.
- */
-struct drm_lock_data {
- struct drm_hw_lock *hw_lock;
- struct drm_file *file_priv;
- wait_queue_head_t lock_queue;
- unsigned long lock_time;
- spinlock_t spinlock;
- uint32_t kernel_waiters;
- uint32_t user_waiters;
- int idle_has_lock;
-};
/**
* struct drm_master - drm master structure
@@ -145,10 +127,6 @@ struct drm_master {
* Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
*/
struct idr lessee_idr;
- /* private: */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- struct drm_lock_data lock;
-#endif
};
struct drm_master *drm_master_get(struct drm_master *master);
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index c490977ee250c..63767cf24371b 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -6,7 +6,6 @@
#include <linux/mutex.h>
#include <linux/idr.h>
-#include <drm/drm_legacy.h>
#include <drm/drm_mode_config.h>
struct drm_driver;
@@ -153,8 +152,8 @@ struct drm_device {
*
* Lock for others (not &drm_minor.master and &drm_file.is_master)
*
- * WARNING:
- * Only drivers annotated with DRIVER_LEGACY should be using this.
+ * TODO: This lock used to be the BKL of the DRM subsystem. Move the
+ * lock into i915, which is the only remaining user.
*/
struct mutex struct_mutex;
@@ -317,72 +316,6 @@ struct drm_device {
* Root directory for debugfs files.
*/
struct dentry *debugfs_root;
-
- /* Everything below here is for legacy driver, never use! */
- /* private: */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- /* List of devices per driver for stealth attach cleanup */
- struct list_head legacy_dev_list;
-
-#ifdef __alpha__
- /** @hose: PCI hose, only used on ALPHA platforms. */
- struct pci_controller *hose;
-#endif
-
- /* AGP data */
- struct drm_agp_head *agp;
-
- /* Context handle management - linked list of context handles */
- struct list_head ctxlist;
-
- /* Context handle management - mutex for &ctxlist */
- struct mutex ctxlist_mutex;
-
- /* Context handle management */
- struct idr ctx_idr;
-
- /* Memory management - linked list of regions */
- struct list_head maplist;
-
- /* Memory management - user token hash table for maps */
- struct drm_open_hash map_hash;
-
- /* Context handle management - list of vmas (for debugging) */
- struct list_head vmalist;
-
- /* Optional pointer for DMA support */
- struct drm_device_dma *dma;
-
- /* Context swapping flag */
- __volatile__ long context_flag;
-
- /* Last current context */
- int last_context;
-
- /* Lock for &buf_use and a few other things. */
- spinlock_t buf_lock;
-
- /* Usage counter for buffers in use -- cannot alloc */
- int buf_use;
-
- /* Buffer allocation in progress */
- atomic_t buf_alloc;
-
- struct {
- int context;
- struct drm_hw_lock *lock;
- } sigdata;
-
- struct drm_local_map *agp_buffer_map;
- unsigned int agp_buffer_token;
-
- /* Scatter gather memory */
- struct drm_sg_mem *sg;
-
- /* IRQs */
- bool irq_enabled;
- int irq;
-#endif
};
#endif
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index e2640dc64e081..0bd2298ba7523 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -433,25 +433,6 @@ struct drm_driver {
* some examples.
*/
const struct file_operations *fops;
-
-#ifdef CONFIG_DRM_LEGACY
- /* Everything below here is for legacy driver, never use! */
- /* private: */
-
- int (*firstopen) (struct drm_device *);
- void (*preclose) (struct drm_device *, struct drm_file *file_priv);
- int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
- int (*dma_quiescent) (struct drm_device *);
- int (*context_dtor) (struct drm_device *dev, int context);
- irqreturn_t (*irq_handler)(int irq, void *arg);
- void (*irq_preinstall)(struct drm_device *dev);
- int (*irq_postinstall)(struct drm_device *dev);
- void (*irq_uninstall)(struct drm_device *dev);
- u32 (*get_vblank_counter)(struct drm_device *dev, unsigned int pipe);
- int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
- void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
- int dev_priv_size;
-#endif
};
void *__devm_drm_dev_alloc(struct device *parent,
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index e1b5b4282f75d..e7e1860d0a342 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -374,11 +374,6 @@ struct drm_file {
* Per-file buffer caches used by the PRIME buffer sharing code.
*/
struct drm_prime_file_private prime;
-
- /* private: */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
- unsigned long lock_count; /* DRI1 legacy lock count */
-#endif
};
/**
diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h
deleted file mode 100644
index 0fc85418aad8c..0000000000000
--- a/include/drm/drm_legacy.h
+++ /dev/null
@@ -1,331 +0,0 @@
-#ifndef __DRM_DRM_LEGACY_H__
-#define __DRM_DRM_LEGACY_H__
-/*
- * Legacy driver interfaces for the Direct Rendering Manager
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * Copyright (c) 2009-2010, Code Aurora Forum.
- * All rights reserved.
- * Copyright © 2014 Intel Corporation
- * Daniel Vetter <daniel.vetter@ffwll.ch>
- *
- * Author: Rickard E. (Rik) Faith <faith@valinux.com>
- * Author: Gareth Hughes <gareth@valinux.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/agp_backend.h>
-
-#include <drm/drm.h>
-#include <drm/drm_auth.h>
-
-struct drm_device;
-struct drm_driver;
-struct file;
-struct pci_driver;
-
-/*
- * Legacy Support for palateontologic DRM drivers
- *
- * If you add a new driver and it uses any of these functions or structures,
- * you're doing it terribly wrong.
- */
-
-/*
- * Hash-table Support
- */
-
-struct drm_hash_item {
- struct hlist_node head;
- unsigned long key;
-};
-
-struct drm_open_hash {
- struct hlist_head *table;
- u8 order;
-};
-
-/**
- * DMA buffer.
- */
-struct drm_buf {
- int idx; /**< Index into master buflist */
- int total; /**< Buffer size */
- int order; /**< log-base-2(total) */
- int used; /**< Amount of buffer in use (for DMA) */
- unsigned long offset; /**< Byte offset (used internally) */
- void *address; /**< Address of buffer */
- unsigned long bus_address; /**< Bus address of buffer */
- struct drm_buf *next; /**< Kernel-only: used for free list */
- __volatile__ int waiting; /**< On kernel DMA queue */
- __volatile__ int pending; /**< On hardware DMA queue */
- struct drm_file *file_priv; /**< Private of holding file descr */
- int context; /**< Kernel queue for this buffer */
- int while_locked; /**< Dispatch this buffer while locked */
- enum {
- DRM_LIST_NONE = 0,
- DRM_LIST_FREE = 1,
- DRM_LIST_WAIT = 2,
- DRM_LIST_PEND = 3,
- DRM_LIST_PRIO = 4,
- DRM_LIST_RECLAIM = 5
- } list; /**< Which list we're on */
-
- int dev_priv_size; /**< Size of buffer private storage */
- void *dev_private; /**< Per-buffer private storage */
-};
-
-typedef struct drm_dma_handle {
- dma_addr_t busaddr;
- void *vaddr;
- size_t size;
-} drm_dma_handle_t;
-
-/**
- * Buffer entry. There is one of this for each buffer size order.
- */
-struct drm_buf_entry {
- int buf_size; /**< size */
- int buf_count; /**< number of buffers */
- struct drm_buf *buflist; /**< buffer list */
- int seg_count;
- int page_order;
- struct drm_dma_handle **seglist;
-
- int low_mark; /**< Low water mark */
- int high_mark; /**< High water mark */
-};
-
-/**
- * DMA data.
- */
-struct drm_device_dma {
-
- struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
- int buf_count; /**< total number of buffers */
- struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */
- int seg_count;
- int page_count; /**< number of pages */
- unsigned long *pagelist; /**< page list */
- unsigned long byte_count;
- enum {
- _DRM_DMA_USE_AGP = 0x01,
- _DRM_DMA_USE_SG = 0x02,
- _DRM_DMA_USE_FB = 0x04,
- _DRM_DMA_USE_PCI_RO = 0x08
- } flags;
-
-};
-
-/**
- * Scatter-gather memory.
- */
-struct drm_sg_mem {
- unsigned long handle;
- void *virtual;
- int pages;
- struct page **pagelist;
- dma_addr_t *busaddr;
-};
-
-/**
- * Kernel side of a mapping
- */
-struct drm_local_map {
- dma_addr_t offset; /**< Requested physical address (0 for SAREA)*/
- unsigned long size; /**< Requested physical size (bytes) */
- enum drm_map_type type; /**< Type of memory to map */
- enum drm_map_flags flags; /**< Flags */
- void *handle; /**< User-space: "Handle" to pass to mmap() */
- /**< Kernel-space: kernel-virtual address */
- int mtrr; /**< MTRR slot used */
-};
-
-typedef struct drm_local_map drm_local_map_t;
-
-/**
- * Mappings list
- */
-struct drm_map_list {
- struct list_head head; /**< list head */
- struct drm_hash_item hash;
- struct drm_local_map *map; /**< mapping */
- uint64_t user_token;
- struct drm_master *master;
-};
-
-int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
- unsigned int size, enum drm_map_type type,
- enum drm_map_flags flags, struct drm_local_map **map_p);
-struct drm_local_map *drm_legacy_findmap(struct drm_device *dev, unsigned int token);
-void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
-int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
-struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
-int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
-
-int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req);
-int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
-
-/**
- * Test that the hardware lock is held by the caller, returning otherwise.
- *
- * \param dev DRM device.
- * \param filp file pointer of the caller.
- */
-#define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \
-do { \
- if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \
- _file_priv->master->lock.file_priv != _file_priv) { \
- DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
- __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
- _file_priv->master->lock.file_priv, _file_priv); \
- return -EINVAL; \
- } \
-} while (0)
-
-void drm_legacy_idlelock_take(struct drm_lock_data *lock);
-void drm_legacy_idlelock_release(struct drm_lock_data *lock);
-
-/* drm_irq.c */
-int drm_legacy_irq_uninstall(struct drm_device *dev);
-
-/* drm_pci.c */
-
-#ifdef CONFIG_PCI
-
-int drm_legacy_pci_init(const struct drm_driver *driver,
- struct pci_driver *pdriver);
-void drm_legacy_pci_exit(const struct drm_driver *driver,
- struct pci_driver *pdriver);
-
-#else
-
-static inline struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev,
- size_t size, size_t align)
-{
- return NULL;
-}
-
-static inline void drm_pci_free(struct drm_device *dev,
- struct drm_dma_handle *dmah)
-{
-}
-
-static inline int drm_legacy_pci_init(const struct drm_driver *driver,
- struct pci_driver *pdriver)
-{
- return -EINVAL;
-}
-
-static inline void drm_legacy_pci_exit(const struct drm_driver *driver,
- struct pci_driver *pdriver)
-{
-}
-
-#endif
-
-/*
- * AGP Support
- */
-
-struct drm_agp_head {
- struct agp_kern_info agp_info;
- struct list_head memory;
- unsigned long mode;
- struct agp_bridge_data *bridge;
- int enabled;
- int acquired;
- unsigned long base;
- int agp_mtrr;
- int cant_use_aperture;
- unsigned long page_mask;
-};
-
-#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
-struct drm_agp_head *drm_legacy_agp_init(struct drm_device *dev);
-int drm_legacy_agp_acquire(struct drm_device *dev);
-int drm_legacy_agp_release(struct drm_device *dev);
-int drm_legacy_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
-int drm_legacy_agp_info(struct drm_device *dev, struct drm_agp_info *info);
-int drm_legacy_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
-int drm_legacy_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
-int drm_legacy_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
-int drm_legacy_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
-#else
-static inline struct drm_agp_head *drm_legacy_agp_init(struct drm_device *dev)
-{
- return NULL;
-}
-
-static inline int drm_legacy_agp_acquire(struct drm_device *dev)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_release(struct drm_device *dev)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_enable(struct drm_device *dev,
- struct drm_agp_mode mode)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_info(struct drm_device *dev,
- struct drm_agp_info *info)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_alloc(struct drm_device *dev,
- struct drm_agp_buffer *request)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_free(struct drm_device *dev,
- struct drm_agp_buffer *request)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_unbind(struct drm_device *dev,
- struct drm_agp_binding *request)
-{
- return -ENODEV;
-}
-
-static inline int drm_legacy_agp_bind(struct drm_device *dev,
- struct drm_agp_binding *request)
-{
- return -ENODEV;
-}
-#endif
-
-/* drm_memory.c */
-void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev);
-void drm_legacy_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
-void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
-
-#endif /* __DRM_DRM_LEGACY_H__ */
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 13/14] char/agp: Remove frontend code
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (11 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 12/14] drm: Remove source code for non-KMS drivers Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:07 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY) Thomas Zimmermann
` (2 subsequent siblings)
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
The AGP subsystem supports a user-space interface via /dev/agpgart. It
is only enabled with DRM support for mode setting in user space. (i.e.,
CONFIG_DRM_LEGACY). All of that DRM code has been removed and the option
will go away. Hence remove the AGP frontend.
Modern DRM drivers with kernel mode setting handle AGP support internally.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/char/agp/Makefile | 6 -
drivers/char/agp/agp.h | 9 -
drivers/char/agp/backend.c | 11 -
drivers/char/agp/compat_ioctl.c | 291 ---------
drivers/char/agp/compat_ioctl.h | 106 ---
drivers/char/agp/frontend.c | 1068 -------------------------------
6 files changed, 1491 deletions(-)
delete mode 100644 drivers/char/agp/compat_ioctl.c
delete mode 100644 drivers/char/agp/compat_ioctl.h
delete mode 100644 drivers/char/agp/frontend.c
diff --git a/drivers/char/agp/Makefile b/drivers/char/agp/Makefile
index 25834557e4865..43b09cf193bb7 100644
--- a/drivers/char/agp/Makefile
+++ b/drivers/char/agp/Makefile
@@ -1,12 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
agpgart-y := backend.o generic.o isoch.o
-ifeq ($(CONFIG_DRM_LEGACY),y)
-agpgart-$(CONFIG_COMPAT) += compat_ioctl.o
-agpgart-y += frontend.o
-endif
-
-
obj-$(CONFIG_AGP) += agpgart.o
obj-$(CONFIG_AGP_ALI) += ali-agp.o
obj-$(CONFIG_AGP_ATI) += ati-agp.o
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index 8771dcc9b8e2f..5c36ab85f80b7 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -185,15 +185,6 @@ void agp_put_bridge(struct agp_bridge_data *bridge);
int agp_add_bridge(struct agp_bridge_data *bridge);
void agp_remove_bridge(struct agp_bridge_data *bridge);
-/* Frontend routines. */
-#if IS_ENABLED(CONFIG_DRM_LEGACY)
-int agp_frontend_initialize(void);
-void agp_frontend_cleanup(void);
-#else
-static inline int agp_frontend_initialize(void) { return 0; }
-static inline void agp_frontend_cleanup(void) {}
-#endif
-
/* Generic routines. */
void agp_generic_enable(struct agp_bridge_data *bridge, u32 mode);
int agp_generic_create_gatt_table(struct agp_bridge_data *bridge);
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 0e19c600db531..1776afd3ee078 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -293,13 +293,6 @@ int agp_add_bridge(struct agp_bridge_data *bridge)
}
if (list_empty(&agp_bridges)) {
- error = agp_frontend_initialize();
- if (error) {
- dev_info(&bridge->dev->dev,
- "agp_frontend_initialize() failed\n");
- goto frontend_err;
- }
-
dev_info(&bridge->dev->dev, "AGP aperture is %dM @ 0x%lx\n",
bridge->driver->fetch_size(), bridge->gart_bus_addr);
@@ -308,8 +301,6 @@ int agp_add_bridge(struct agp_bridge_data *bridge)
list_add(&bridge->list, &agp_bridges);
return 0;
-frontend_err:
- agp_backend_cleanup(bridge);
err_out:
module_put(bridge->driver->owner);
err_put_bridge:
@@ -323,8 +314,6 @@ void agp_remove_bridge(struct agp_bridge_data *bridge)
{
agp_backend_cleanup(bridge);
list_del(&bridge->list);
- if (list_empty(&agp_bridges))
- agp_frontend_cleanup();
module_put(bridge->driver->owner);
}
EXPORT_SYMBOL_GPL(agp_remove_bridge);
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
deleted file mode 100644
index 52ffe1706ce05..0000000000000
--- a/drivers/char/agp/compat_ioctl.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * AGPGART driver frontend compatibility ioctls
- * Copyright (C) 2004 Silicon Graphics, Inc.
- * Copyright (C) 2002-2003 Dave Jones
- * Copyright (C) 1999 Jeff Hartmann
- * Copyright (C) 1999 Precision Insight, Inc.
- * Copyright (C) 1999 Xi Graphics, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/fs.h>
-#include <linux/agpgart.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include "agp.h"
-#include "compat_ioctl.h"
-
-static int compat_agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_info32 userinfo;
- struct agp_kern_info kerninfo;
-
- agp_copy_info(agp_bridge, &kerninfo);
-
- userinfo.version.major = kerninfo.version.major;
- userinfo.version.minor = kerninfo.version.minor;
- userinfo.bridge_id = kerninfo.device->vendor |
- (kerninfo.device->device << 16);
- userinfo.agp_mode = kerninfo.mode;
- userinfo.aper_base = (compat_long_t)kerninfo.aper_base;
- userinfo.aper_size = kerninfo.aper_size;
- userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
- userinfo.pg_used = kerninfo.current_memory;
-
- if (copy_to_user(arg, &userinfo, sizeof(userinfo)))
- return -EFAULT;
-
- return 0;
-}
-
-static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_region32 ureserve;
- struct agp_region kreserve;
- struct agp_client *client;
- struct agp_file_private *client_priv;
-
- DBG("");
- if (copy_from_user(&ureserve, arg, sizeof(ureserve)))
- return -EFAULT;
-
- if ((unsigned) ureserve.seg_count >= ~0U/sizeof(struct agp_segment32))
- return -EFAULT;
-
- kreserve.pid = ureserve.pid;
- kreserve.seg_count = ureserve.seg_count;
-
- client = agp_find_client_by_pid(kreserve.pid);
-
- if (kreserve.seg_count == 0) {
- /* remove a client */
- client_priv = agp_find_private(kreserve.pid);
-
- if (client_priv != NULL) {
- set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
- set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
- }
- if (client == NULL) {
- /* client is already removed */
- return 0;
- }
- return agp_remove_client(kreserve.pid);
- } else {
- struct agp_segment32 *usegment;
- struct agp_segment *ksegment;
- int seg;
-
- if (ureserve.seg_count >= 16384)
- return -EINVAL;
-
- usegment = kmalloc_array(ureserve.seg_count,
- sizeof(*usegment),
- GFP_KERNEL);
- if (!usegment)
- return -ENOMEM;
-
- ksegment = kmalloc_array(kreserve.seg_count,
- sizeof(*ksegment),
- GFP_KERNEL);
- if (!ksegment) {
- kfree(usegment);
- return -ENOMEM;
- }
-
- if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
- sizeof(*usegment) * ureserve.seg_count)) {
- kfree(usegment);
- kfree(ksegment);
- return -EFAULT;
- }
-
- for (seg = 0; seg < ureserve.seg_count; seg++) {
- ksegment[seg].pg_start = usegment[seg].pg_start;
- ksegment[seg].pg_count = usegment[seg].pg_count;
- ksegment[seg].prot = usegment[seg].prot;
- }
-
- kfree(usegment);
- kreserve.seg_list = ksegment;
-
- if (client == NULL) {
- /* Create the client and add the segment */
- client = agp_create_client(kreserve.pid);
-
- if (client == NULL) {
- kfree(ksegment);
- return -ENOMEM;
- }
- client_priv = agp_find_private(kreserve.pid);
-
- if (client_priv != NULL) {
- set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
- set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
- }
- }
- return agp_create_segment(client, &kreserve);
- }
- /* Will never really happen */
- return -EINVAL;
-}
-
-static int compat_agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_memory *memory;
- struct agp_allocate32 alloc;
-
- DBG("");
- if (copy_from_user(&alloc, arg, sizeof(alloc)))
- return -EFAULT;
-
- memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
-
- if (memory == NULL)
- return -ENOMEM;
-
- alloc.key = memory->key;
- alloc.physical = memory->physical;
-
- if (copy_to_user(arg, &alloc, sizeof(alloc))) {
- agp_free_memory_wrap(memory);
- return -EFAULT;
- }
- return 0;
-}
-
-static int compat_agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_bind32 bind_info;
- struct agp_memory *memory;
-
- DBG("");
- if (copy_from_user(&bind_info, arg, sizeof(bind_info)))
- return -EFAULT;
-
- memory = agp_find_mem_by_key(bind_info.key);
-
- if (memory == NULL)
- return -EINVAL;
-
- return agp_bind_memory(memory, bind_info.pg_start);
-}
-
-static int compat_agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_memory *memory;
- struct agp_unbind32 unbind;
-
- DBG("");
- if (copy_from_user(&unbind, arg, sizeof(unbind)))
- return -EFAULT;
-
- memory = agp_find_mem_by_key(unbind.key);
-
- if (memory == NULL)
- return -EINVAL;
-
- return agp_unbind_memory(memory);
-}
-
-long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- struct agp_file_private *curr_priv = file->private_data;
- int ret_val = -ENOTTY;
-
- mutex_lock(&(agp_fe.agp_mutex));
-
- if ((agp_fe.current_controller == NULL) &&
- (cmd != AGPIOC_ACQUIRE32)) {
- ret_val = -EINVAL;
- goto ioctl_out;
- }
- if ((agp_fe.backend_acquired != true) &&
- (cmd != AGPIOC_ACQUIRE32)) {
- ret_val = -EBUSY;
- goto ioctl_out;
- }
- if (cmd != AGPIOC_ACQUIRE32) {
- if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
- ret_val = -EPERM;
- goto ioctl_out;
- }
- /* Use the original pid of the controller,
- * in case it's threaded */
-
- if (agp_fe.current_controller->pid != curr_priv->my_pid) {
- ret_val = -EBUSY;
- goto ioctl_out;
- }
- }
-
- switch (cmd) {
- case AGPIOC_INFO32:
- ret_val = compat_agpioc_info_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_ACQUIRE32:
- ret_val = agpioc_acquire_wrap(curr_priv);
- break;
-
- case AGPIOC_RELEASE32:
- ret_val = agpioc_release_wrap(curr_priv);
- break;
-
- case AGPIOC_SETUP32:
- ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_RESERVE32:
- ret_val = compat_agpioc_reserve_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_PROTECT32:
- ret_val = agpioc_protect_wrap(curr_priv);
- break;
-
- case AGPIOC_ALLOCATE32:
- ret_val = compat_agpioc_allocate_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_DEALLOCATE32:
- ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
- break;
-
- case AGPIOC_BIND32:
- ret_val = compat_agpioc_bind_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_UNBIND32:
- ret_val = compat_agpioc_unbind_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_CHIPSET_FLUSH32:
- break;
- }
-
-ioctl_out:
- DBG("ioctl returns %d\n", ret_val);
- mutex_unlock(&(agp_fe.agp_mutex));
- return ret_val;
-}
-
diff --git a/drivers/char/agp/compat_ioctl.h b/drivers/char/agp/compat_ioctl.h
deleted file mode 100644
index f30e0fd979635..0000000000000
--- a/drivers/char/agp/compat_ioctl.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 1999 Jeff Hartmann
- * Copyright (C) 1999 Precision Insight, Inc.
- * Copyright (C) 1999 Xi Graphics, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifndef _AGP_COMPAT_IOCTL_H
-#define _AGP_COMPAT_IOCTL_H
-
-#include <linux/compat.h>
-#include <linux/agpgart.h>
-
-#define AGPIOC_INFO32 _IOR (AGPIOC_BASE, 0, compat_uptr_t)
-#define AGPIOC_ACQUIRE32 _IO (AGPIOC_BASE, 1)
-#define AGPIOC_RELEASE32 _IO (AGPIOC_BASE, 2)
-#define AGPIOC_SETUP32 _IOW (AGPIOC_BASE, 3, compat_uptr_t)
-#define AGPIOC_RESERVE32 _IOW (AGPIOC_BASE, 4, compat_uptr_t)
-#define AGPIOC_PROTECT32 _IOW (AGPIOC_BASE, 5, compat_uptr_t)
-#define AGPIOC_ALLOCATE32 _IOWR(AGPIOC_BASE, 6, compat_uptr_t)
-#define AGPIOC_DEALLOCATE32 _IOW (AGPIOC_BASE, 7, compat_int_t)
-#define AGPIOC_BIND32 _IOW (AGPIOC_BASE, 8, compat_uptr_t)
-#define AGPIOC_UNBIND32 _IOW (AGPIOC_BASE, 9, compat_uptr_t)
-#define AGPIOC_CHIPSET_FLUSH32 _IO (AGPIOC_BASE, 10)
-
-struct agp_info32 {
- struct agp_version version; /* version of the driver */
- u32 bridge_id; /* bridge vendor/device */
- u32 agp_mode; /* mode info of bridge */
- compat_long_t aper_base; /* base of aperture */
- compat_size_t aper_size; /* size of aperture */
- compat_size_t pg_total; /* max pages (swap + system) */
- compat_size_t pg_system; /* max pages (system) */
- compat_size_t pg_used; /* current pages used */
-};
-
-/*
- * The "prot" down below needs still a "sleep" flag somehow ...
- */
-struct agp_segment32 {
- compat_off_t pg_start; /* starting page to populate */
- compat_size_t pg_count; /* number of pages */
- compat_int_t prot; /* prot flags for mmap */
-};
-
-struct agp_region32 {
- compat_pid_t pid; /* pid of process */
- compat_size_t seg_count; /* number of segments */
- struct agp_segment32 *seg_list;
-};
-
-struct agp_allocate32 {
- compat_int_t key; /* tag of allocation */
- compat_size_t pg_count; /* number of pages */
- u32 type; /* 0 == normal, other devspec */
- u32 physical; /* device specific (some devices
- * need a phys address of the
- * actual page behind the gatt
- * table) */
-};
-
-struct agp_bind32 {
- compat_int_t key; /* tag of allocation */
- compat_off_t pg_start; /* starting page to populate */
-};
-
-struct agp_unbind32 {
- compat_int_t key; /* tag of allocation */
- u32 priority; /* priority for paging out */
-};
-
-extern struct agp_front_data agp_fe;
-
-int agpioc_acquire_wrap(struct agp_file_private *priv);
-int agpioc_release_wrap(struct agp_file_private *priv);
-int agpioc_protect_wrap(struct agp_file_private *priv);
-int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg);
-int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg);
-struct agp_file_private *agp_find_private(pid_t pid);
-struct agp_client *agp_create_client(pid_t id);
-int agp_remove_client(pid_t id);
-int agp_create_segment(struct agp_client *client, struct agp_region *region);
-void agp_free_memory_wrap(struct agp_memory *memory);
-struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type);
-struct agp_memory *agp_find_mem_by_key(int key);
-struct agp_client *agp_find_client_by_pid(pid_t id);
-
-#endif /* _AGP_COMPAT_H */
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
deleted file mode 100644
index 321118a9cfa52..0000000000000
--- a/drivers/char/agp/frontend.c
+++ /dev/null
@@ -1,1068 +0,0 @@
-/*
- * AGPGART driver frontend
- * Copyright (C) 2004 Silicon Graphics, Inc.
- * Copyright (C) 2002-2003 Dave Jones
- * Copyright (C) 1999 Jeff Hartmann
- * Copyright (C) 1999 Precision Insight, Inc.
- * Copyright (C) 1999 Xi Graphics, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/mman.h>
-#include <linux/pci.h>
-#include <linux/miscdevice.h>
-#include <linux/agp_backend.h>
-#include <linux/agpgart.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-
-#include "agp.h"
-#include "compat_ioctl.h"
-
-struct agp_front_data agp_fe;
-
-struct agp_memory *agp_find_mem_by_key(int key)
-{
- struct agp_memory *curr;
-
- if (agp_fe.current_controller == NULL)
- return NULL;
-
- curr = agp_fe.current_controller->pool;
-
- while (curr != NULL) {
- if (curr->key == key)
- break;
- curr = curr->next;
- }
-
- DBG("key=%d -> mem=%p", key, curr);
- return curr;
-}
-
-static void agp_remove_from_pool(struct agp_memory *temp)
-{
- struct agp_memory *prev;
- struct agp_memory *next;
-
- /* Check to see if this is even in the memory pool */
-
- DBG("mem=%p", temp);
- if (agp_find_mem_by_key(temp->key) != NULL) {
- next = temp->next;
- prev = temp->prev;
-
- if (prev != NULL) {
- prev->next = next;
- if (next != NULL)
- next->prev = prev;
-
- } else {
- /* This is the first item on the list */
- if (next != NULL)
- next->prev = NULL;
-
- agp_fe.current_controller->pool = next;
- }
- }
-}
-
-/*
- * Routines for managing each client's segment list -
- * These routines handle adding and removing segments
- * to each auth'ed client.
- */
-
-static struct
-agp_segment_priv *agp_find_seg_in_client(const struct agp_client *client,
- unsigned long offset,
- int size, pgprot_t page_prot)
-{
- struct agp_segment_priv *seg;
- int i;
- off_t pg_start;
- size_t pg_count;
-
- pg_start = offset / 4096;
- pg_count = size / 4096;
- seg = *(client->segments);
-
- for (i = 0; i < client->num_segments; i++) {
- if ((seg[i].pg_start == pg_start) &&
- (seg[i].pg_count == pg_count) &&
- (pgprot_val(seg[i].prot) == pgprot_val(page_prot))) {
- return seg + i;
- }
- }
-
- return NULL;
-}
-
-static void agp_remove_seg_from_client(struct agp_client *client)
-{
- DBG("client=%p", client);
-
- if (client->segments != NULL) {
- if (*(client->segments) != NULL) {
- DBG("Freeing %p from client %p", *(client->segments), client);
- kfree(*(client->segments));
- }
- DBG("Freeing %p from client %p", client->segments, client);
- kfree(client->segments);
- client->segments = NULL;
- }
-}
-
-static void agp_add_seg_to_client(struct agp_client *client,
- struct agp_segment_priv ** seg, int num_segments)
-{
- struct agp_segment_priv **prev_seg;
-
- prev_seg = client->segments;
-
- if (prev_seg != NULL)
- agp_remove_seg_from_client(client);
-
- DBG("Adding seg %p (%d segments) to client %p", seg, num_segments, client);
- client->num_segments = num_segments;
- client->segments = seg;
-}
-
-static pgprot_t agp_convert_mmap_flags(int prot)
-{
- unsigned long prot_bits;
-
- prot_bits = calc_vm_prot_bits(prot, 0) | VM_SHARED;
- return vm_get_page_prot(prot_bits);
-}
-
-int agp_create_segment(struct agp_client *client, struct agp_region *region)
-{
- struct agp_segment_priv **ret_seg;
- struct agp_segment_priv *seg;
- struct agp_segment *user_seg;
- size_t i;
-
- seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
- if (seg == NULL) {
- kfree(region->seg_list);
- region->seg_list = NULL;
- return -ENOMEM;
- }
- user_seg = region->seg_list;
-
- for (i = 0; i < region->seg_count; i++) {
- seg[i].pg_start = user_seg[i].pg_start;
- seg[i].pg_count = user_seg[i].pg_count;
- seg[i].prot = agp_convert_mmap_flags(user_seg[i].prot);
- }
- kfree(region->seg_list);
- region->seg_list = NULL;
-
- ret_seg = kmalloc(sizeof(void *), GFP_KERNEL);
- if (ret_seg == NULL) {
- kfree(seg);
- return -ENOMEM;
- }
- *ret_seg = seg;
- agp_add_seg_to_client(client, ret_seg, region->seg_count);
- return 0;
-}
-
-/* End - Routines for managing each client's segment list */
-
-/* This function must only be called when current_controller != NULL */
-static void agp_insert_into_pool(struct agp_memory * temp)
-{
- struct agp_memory *prev;
-
- prev = agp_fe.current_controller->pool;
-
- if (prev != NULL) {
- prev->prev = temp;
- temp->next = prev;
- }
- agp_fe.current_controller->pool = temp;
-}
-
-
-/* File private list routines */
-
-struct agp_file_private *agp_find_private(pid_t pid)
-{
- struct agp_file_private *curr;
-
- curr = agp_fe.file_priv_list;
-
- while (curr != NULL) {
- if (curr->my_pid == pid)
- return curr;
- curr = curr->next;
- }
-
- return NULL;
-}
-
-static void agp_insert_file_private(struct agp_file_private * priv)
-{
- struct agp_file_private *prev;
-
- prev = agp_fe.file_priv_list;
-
- if (prev != NULL)
- prev->prev = priv;
- priv->next = prev;
- agp_fe.file_priv_list = priv;
-}
-
-static void agp_remove_file_private(struct agp_file_private * priv)
-{
- struct agp_file_private *next;
- struct agp_file_private *prev;
-
- next = priv->next;
- prev = priv->prev;
-
- if (prev != NULL) {
- prev->next = next;
-
- if (next != NULL)
- next->prev = prev;
-
- } else {
- if (next != NULL)
- next->prev = NULL;
-
- agp_fe.file_priv_list = next;
- }
-}
-
-/* End - File flag list routines */
-
-/*
- * Wrappers for agp_free_memory & agp_allocate_memory
- * These make sure that internal lists are kept updated.
- */
-void agp_free_memory_wrap(struct agp_memory *memory)
-{
- agp_remove_from_pool(memory);
- agp_free_memory(memory);
-}
-
-struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
-{
- struct agp_memory *memory;
-
- memory = agp_allocate_memory(agp_bridge, pg_count, type);
- if (memory == NULL)
- return NULL;
-
- agp_insert_into_pool(memory);
- return memory;
-}
-
-/* Routines for managing the list of controllers -
- * These routines manage the current controller, and the list of
- * controllers
- */
-
-static struct agp_controller *agp_find_controller_by_pid(pid_t id)
-{
- struct agp_controller *controller;
-
- controller = agp_fe.controllers;
-
- while (controller != NULL) {
- if (controller->pid == id)
- return controller;
- controller = controller->next;
- }
-
- return NULL;
-}
-
-static struct agp_controller *agp_create_controller(pid_t id)
-{
- struct agp_controller *controller;
-
- controller = kzalloc(sizeof(struct agp_controller), GFP_KERNEL);
- if (controller == NULL)
- return NULL;
-
- controller->pid = id;
- return controller;
-}
-
-static int agp_insert_controller(struct agp_controller *controller)
-{
- struct agp_controller *prev_controller;
-
- prev_controller = agp_fe.controllers;
- controller->next = prev_controller;
-
- if (prev_controller != NULL)
- prev_controller->prev = controller;
-
- agp_fe.controllers = controller;
-
- return 0;
-}
-
-static void agp_remove_all_clients(struct agp_controller *controller)
-{
- struct agp_client *client;
- struct agp_client *temp;
-
- client = controller->clients;
-
- while (client) {
- struct agp_file_private *priv;
-
- temp = client;
- agp_remove_seg_from_client(temp);
- priv = agp_find_private(temp->pid);
-
- if (priv != NULL) {
- clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
- clear_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
- }
- client = client->next;
- kfree(temp);
- }
-}
-
-static void agp_remove_all_memory(struct agp_controller *controller)
-{
- struct agp_memory *memory;
- struct agp_memory *temp;
-
- memory = controller->pool;
-
- while (memory) {
- temp = memory;
- memory = memory->next;
- agp_free_memory_wrap(temp);
- }
-}
-
-static int agp_remove_controller(struct agp_controller *controller)
-{
- struct agp_controller *prev_controller;
- struct agp_controller *next_controller;
-
- prev_controller = controller->prev;
- next_controller = controller->next;
-
- if (prev_controller != NULL) {
- prev_controller->next = next_controller;
- if (next_controller != NULL)
- next_controller->prev = prev_controller;
-
- } else {
- if (next_controller != NULL)
- next_controller->prev = NULL;
-
- agp_fe.controllers = next_controller;
- }
-
- agp_remove_all_memory(controller);
- agp_remove_all_clients(controller);
-
- if (agp_fe.current_controller == controller) {
- agp_fe.current_controller = NULL;
- agp_fe.backend_acquired = false;
- agp_backend_release(agp_bridge);
- }
- kfree(controller);
- return 0;
-}
-
-static void agp_controller_make_current(struct agp_controller *controller)
-{
- struct agp_client *clients;
-
- clients = controller->clients;
-
- while (clients != NULL) {
- struct agp_file_private *priv;
-
- priv = agp_find_private(clients->pid);
-
- if (priv != NULL) {
- set_bit(AGP_FF_IS_VALID, &priv->access_flags);
- set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
- }
- clients = clients->next;
- }
-
- agp_fe.current_controller = controller;
-}
-
-static void agp_controller_release_current(struct agp_controller *controller,
- struct agp_file_private *controller_priv)
-{
- struct agp_client *clients;
-
- clear_bit(AGP_FF_IS_VALID, &controller_priv->access_flags);
- clients = controller->clients;
-
- while (clients != NULL) {
- struct agp_file_private *priv;
-
- priv = agp_find_private(clients->pid);
-
- if (priv != NULL)
- clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
-
- clients = clients->next;
- }
-
- agp_fe.current_controller = NULL;
- agp_fe.used_by_controller = false;
- agp_backend_release(agp_bridge);
-}
-
-/*
- * Routines for managing client lists -
- * These routines are for managing the list of auth'ed clients.
- */
-
-static struct agp_client
-*agp_find_client_in_controller(struct agp_controller *controller, pid_t id)
-{
- struct agp_client *client;
-
- if (controller == NULL)
- return NULL;
-
- client = controller->clients;
-
- while (client != NULL) {
- if (client->pid == id)
- return client;
- client = client->next;
- }
-
- return NULL;
-}
-
-static struct agp_controller *agp_find_controller_for_client(pid_t id)
-{
- struct agp_controller *controller;
-
- controller = agp_fe.controllers;
-
- while (controller != NULL) {
- if ((agp_find_client_in_controller(controller, id)) != NULL)
- return controller;
- controller = controller->next;
- }
-
- return NULL;
-}
-
-struct agp_client *agp_find_client_by_pid(pid_t id)
-{
- struct agp_client *temp;
-
- if (agp_fe.current_controller == NULL)
- return NULL;
-
- temp = agp_find_client_in_controller(agp_fe.current_controller, id);
- return temp;
-}
-
-static void agp_insert_client(struct agp_client *client)
-{
- struct agp_client *prev_client;
-
- prev_client = agp_fe.current_controller->clients;
- client->next = prev_client;
-
- if (prev_client != NULL)
- prev_client->prev = client;
-
- agp_fe.current_controller->clients = client;
- agp_fe.current_controller->num_clients++;
-}
-
-struct agp_client *agp_create_client(pid_t id)
-{
- struct agp_client *new_client;
-
- new_client = kzalloc(sizeof(struct agp_client), GFP_KERNEL);
- if (new_client == NULL)
- return NULL;
-
- new_client->pid = id;
- agp_insert_client(new_client);
- return new_client;
-}
-
-int agp_remove_client(pid_t id)
-{
- struct agp_client *client;
- struct agp_client *prev_client;
- struct agp_client *next_client;
- struct agp_controller *controller;
-
- controller = agp_find_controller_for_client(id);
- if (controller == NULL)
- return -EINVAL;
-
- client = agp_find_client_in_controller(controller, id);
- if (client == NULL)
- return -EINVAL;
-
- prev_client = client->prev;
- next_client = client->next;
-
- if (prev_client != NULL) {
- prev_client->next = next_client;
- if (next_client != NULL)
- next_client->prev = prev_client;
-
- } else {
- if (next_client != NULL)
- next_client->prev = NULL;
- controller->clients = next_client;
- }
-
- controller->num_clients--;
- agp_remove_seg_from_client(client);
- kfree(client);
- return 0;
-}
-
-/* End - Routines for managing client lists */
-
-/* File Operations */
-
-static int agp_mmap(struct file *file, struct vm_area_struct *vma)
-{
- unsigned int size, current_size;
- unsigned long offset;
- struct agp_client *client;
- struct agp_file_private *priv = file->private_data;
- struct agp_kern_info kerninfo;
-
- mutex_lock(&(agp_fe.agp_mutex));
-
- if (agp_fe.backend_acquired != true)
- goto out_eperm;
-
- if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
- goto out_eperm;
-
- agp_copy_info(agp_bridge, &kerninfo);
- size = vma->vm_end - vma->vm_start;
- current_size = kerninfo.aper_size;
- current_size = current_size * 0x100000;
- offset = vma->vm_pgoff << PAGE_SHIFT;
- DBG("%lx:%lx", offset, offset+size);
-
- if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) {
- if ((size + offset) > current_size)
- goto out_inval;
-
- client = agp_find_client_by_pid(current->pid);
-
- if (client == NULL)
- goto out_eperm;
-
- if (!agp_find_seg_in_client(client, offset, size, vma->vm_page_prot))
- goto out_inval;
-
- DBG("client vm_ops=%p", kerninfo.vm_ops);
- if (kerninfo.vm_ops) {
- vma->vm_ops = kerninfo.vm_ops;
- } else if (io_remap_pfn_range(vma, vma->vm_start,
- (kerninfo.aper_base + offset) >> PAGE_SHIFT,
- size,
- pgprot_writecombine(vma->vm_page_prot))) {
- goto out_again;
- }
- mutex_unlock(&(agp_fe.agp_mutex));
- return 0;
- }
-
- if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
- if (size != current_size)
- goto out_inval;
-
- DBG("controller vm_ops=%p", kerninfo.vm_ops);
- if (kerninfo.vm_ops) {
- vma->vm_ops = kerninfo.vm_ops;
- } else if (io_remap_pfn_range(vma, vma->vm_start,
- kerninfo.aper_base >> PAGE_SHIFT,
- size,
- pgprot_writecombine(vma->vm_page_prot))) {
- goto out_again;
- }
- mutex_unlock(&(agp_fe.agp_mutex));
- return 0;
- }
-
-out_eperm:
- mutex_unlock(&(agp_fe.agp_mutex));
- return -EPERM;
-
-out_inval:
- mutex_unlock(&(agp_fe.agp_mutex));
- return -EINVAL;
-
-out_again:
- mutex_unlock(&(agp_fe.agp_mutex));
- return -EAGAIN;
-}
-
-static int agp_release(struct inode *inode, struct file *file)
-{
- struct agp_file_private *priv = file->private_data;
-
- mutex_lock(&(agp_fe.agp_mutex));
-
- DBG("priv=%p", priv);
-
- if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
- struct agp_controller *controller;
-
- controller = agp_find_controller_by_pid(priv->my_pid);
-
- if (controller != NULL) {
- if (controller == agp_fe.current_controller)
- agp_controller_release_current(controller, priv);
- agp_remove_controller(controller);
- controller = NULL;
- }
- }
-
- if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags))
- agp_remove_client(priv->my_pid);
-
- agp_remove_file_private(priv);
- kfree(priv);
- file->private_data = NULL;
- mutex_unlock(&(agp_fe.agp_mutex));
- return 0;
-}
-
-static int agp_open(struct inode *inode, struct file *file)
-{
- int minor = iminor(inode);
- struct agp_file_private *priv;
- struct agp_client *client;
-
- if (minor != AGPGART_MINOR)
- return -ENXIO;
-
- mutex_lock(&(agp_fe.agp_mutex));
-
- priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
- if (priv == NULL) {
- mutex_unlock(&(agp_fe.agp_mutex));
- return -ENOMEM;
- }
-
- set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
- priv->my_pid = current->pid;
-
- if (capable(CAP_SYS_RAWIO))
- /* Root priv, can be controller */
- set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags);
-
- client = agp_find_client_by_pid(current->pid);
-
- if (client != NULL) {
- set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
- set_bit(AGP_FF_IS_VALID, &priv->access_flags);
- }
- file->private_data = (void *) priv;
- agp_insert_file_private(priv);
- DBG("private=%p, client=%p", priv, client);
-
- mutex_unlock(&(agp_fe.agp_mutex));
-
- return 0;
-}
-
-static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_info userinfo;
- struct agp_kern_info kerninfo;
-
- agp_copy_info(agp_bridge, &kerninfo);
-
- memset(&userinfo, 0, sizeof(userinfo));
- userinfo.version.major = kerninfo.version.major;
- userinfo.version.minor = kerninfo.version.minor;
- userinfo.bridge_id = kerninfo.device->vendor |
- (kerninfo.device->device << 16);
- userinfo.agp_mode = kerninfo.mode;
- userinfo.aper_base = kerninfo.aper_base;
- userinfo.aper_size = kerninfo.aper_size;
- userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
- userinfo.pg_used = kerninfo.current_memory;
-
- if (copy_to_user(arg, &userinfo, sizeof(struct agp_info)))
- return -EFAULT;
-
- return 0;
-}
-
-int agpioc_acquire_wrap(struct agp_file_private *priv)
-{
- struct agp_controller *controller;
-
- DBG("");
-
- if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags)))
- return -EPERM;
-
- if (agp_fe.current_controller != NULL)
- return -EBUSY;
-
- if (!agp_bridge)
- return -ENODEV;
-
- if (atomic_read(&agp_bridge->agp_in_use))
- return -EBUSY;
-
- atomic_inc(&agp_bridge->agp_in_use);
-
- agp_fe.backend_acquired = true;
-
- controller = agp_find_controller_by_pid(priv->my_pid);
-
- if (controller != NULL) {
- agp_controller_make_current(controller);
- } else {
- controller = agp_create_controller(priv->my_pid);
-
- if (controller == NULL) {
- agp_fe.backend_acquired = false;
- agp_backend_release(agp_bridge);
- return -ENOMEM;
- }
- agp_insert_controller(controller);
- agp_controller_make_current(controller);
- }
-
- set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags);
- set_bit(AGP_FF_IS_VALID, &priv->access_flags);
- return 0;
-}
-
-int agpioc_release_wrap(struct agp_file_private *priv)
-{
- DBG("");
- agp_controller_release_current(agp_fe.current_controller, priv);
- return 0;
-}
-
-int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_setup mode;
-
- DBG("");
- if (copy_from_user(&mode, arg, sizeof(struct agp_setup)))
- return -EFAULT;
-
- agp_enable(agp_bridge, mode.agp_mode);
- return 0;
-}
-
-static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_region reserve;
- struct agp_client *client;
- struct agp_file_private *client_priv;
-
- DBG("");
- if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
- return -EFAULT;
-
- if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
- return -EFAULT;
-
- client = agp_find_client_by_pid(reserve.pid);
-
- if (reserve.seg_count == 0) {
- /* remove a client */
- client_priv = agp_find_private(reserve.pid);
-
- if (client_priv != NULL) {
- set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
- set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
- }
- if (client == NULL) {
- /* client is already removed */
- return 0;
- }
- return agp_remove_client(reserve.pid);
- } else {
- struct agp_segment *segment;
-
- if (reserve.seg_count >= 16384)
- return -EINVAL;
-
- segment = kmalloc((sizeof(struct agp_segment) * reserve.seg_count),
- GFP_KERNEL);
-
- if (segment == NULL)
- return -ENOMEM;
-
- if (copy_from_user(segment, (void __user *) reserve.seg_list,
- sizeof(struct agp_segment) * reserve.seg_count)) {
- kfree(segment);
- return -EFAULT;
- }
- reserve.seg_list = segment;
-
- if (client == NULL) {
- /* Create the client and add the segment */
- client = agp_create_client(reserve.pid);
-
- if (client == NULL) {
- kfree(segment);
- return -ENOMEM;
- }
- client_priv = agp_find_private(reserve.pid);
-
- if (client_priv != NULL) {
- set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
- set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
- }
- }
- return agp_create_segment(client, &reserve);
- }
- /* Will never really happen */
- return -EINVAL;
-}
-
-int agpioc_protect_wrap(struct agp_file_private *priv)
-{
- DBG("");
- /* This function is not currently implemented */
- return -EINVAL;
-}
-
-static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_memory *memory;
- struct agp_allocate alloc;
-
- DBG("");
- if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate)))
- return -EFAULT;
-
- if (alloc.type >= AGP_USER_TYPES)
- return -EINVAL;
-
- memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
-
- if (memory == NULL)
- return -ENOMEM;
-
- alloc.key = memory->key;
- alloc.physical = memory->physical;
-
- if (copy_to_user(arg, &alloc, sizeof(struct agp_allocate))) {
- agp_free_memory_wrap(memory);
- return -EFAULT;
- }
- return 0;
-}
-
-int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg)
-{
- struct agp_memory *memory;
-
- DBG("");
- memory = agp_find_mem_by_key(arg);
-
- if (memory == NULL)
- return -EINVAL;
-
- agp_free_memory_wrap(memory);
- return 0;
-}
-
-static int agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_bind bind_info;
- struct agp_memory *memory;
-
- DBG("");
- if (copy_from_user(&bind_info, arg, sizeof(struct agp_bind)))
- return -EFAULT;
-
- memory = agp_find_mem_by_key(bind_info.key);
-
- if (memory == NULL)
- return -EINVAL;
-
- return agp_bind_memory(memory, bind_info.pg_start);
-}
-
-static int agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
-{
- struct agp_memory *memory;
- struct agp_unbind unbind;
-
- DBG("");
- if (copy_from_user(&unbind, arg, sizeof(struct agp_unbind)))
- return -EFAULT;
-
- memory = agp_find_mem_by_key(unbind.key);
-
- if (memory == NULL)
- return -EINVAL;
-
- return agp_unbind_memory(memory);
-}
-
-static long agp_ioctl(struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- struct agp_file_private *curr_priv = file->private_data;
- int ret_val = -ENOTTY;
-
- DBG("priv=%p, cmd=%x", curr_priv, cmd);
- mutex_lock(&(agp_fe.agp_mutex));
-
- if ((agp_fe.current_controller == NULL) &&
- (cmd != AGPIOC_ACQUIRE)) {
- ret_val = -EINVAL;
- goto ioctl_out;
- }
- if ((agp_fe.backend_acquired != true) &&
- (cmd != AGPIOC_ACQUIRE)) {
- ret_val = -EBUSY;
- goto ioctl_out;
- }
- if (cmd != AGPIOC_ACQUIRE) {
- if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
- ret_val = -EPERM;
- goto ioctl_out;
- }
- /* Use the original pid of the controller,
- * in case it's threaded */
-
- if (agp_fe.current_controller->pid != curr_priv->my_pid) {
- ret_val = -EBUSY;
- goto ioctl_out;
- }
- }
-
- switch (cmd) {
- case AGPIOC_INFO:
- ret_val = agpioc_info_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_ACQUIRE:
- ret_val = agpioc_acquire_wrap(curr_priv);
- break;
-
- case AGPIOC_RELEASE:
- ret_val = agpioc_release_wrap(curr_priv);
- break;
-
- case AGPIOC_SETUP:
- ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_RESERVE:
- ret_val = agpioc_reserve_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_PROTECT:
- ret_val = agpioc_protect_wrap(curr_priv);
- break;
-
- case AGPIOC_ALLOCATE:
- ret_val = agpioc_allocate_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_DEALLOCATE:
- ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
- break;
-
- case AGPIOC_BIND:
- ret_val = agpioc_bind_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_UNBIND:
- ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
- break;
-
- case AGPIOC_CHIPSET_FLUSH:
- break;
- }
-
-ioctl_out:
- DBG("ioctl returns %d\n", ret_val);
- mutex_unlock(&(agp_fe.agp_mutex));
- return ret_val;
-}
-
-static const struct file_operations agp_fops =
-{
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .unlocked_ioctl = agp_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = compat_agp_ioctl,
-#endif
- .mmap = agp_mmap,
- .open = agp_open,
- .release = agp_release,
-};
-
-static struct miscdevice agp_miscdev =
-{
- .minor = AGPGART_MINOR,
- .name = "agpgart",
- .fops = &agp_fops
-};
-
-int agp_frontend_initialize(void)
-{
- memset(&agp_fe, 0, sizeof(struct agp_front_data));
- mutex_init(&(agp_fe.agp_mutex));
-
- if (misc_register(&agp_miscdev)) {
- printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR);
- return -EIO;
- }
- return 0;
-}
-
-void agp_frontend_cleanup(void)
-{
- misc_deregister(&agp_miscdev);
-}
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY)
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (12 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 13/14] char/agp: Remove frontend code Thomas Zimmermann
@ 2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:07 ` Alex Deucher
2023-12-01 8:39 ` [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
2023-12-06 9:20 ` Thomas Zimmermann
15 siblings, 1 reply; 39+ messages in thread
From: Thomas Zimmermann @ 2023-11-22 12:09 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing
Cc: Thomas Zimmermann, dri-devel
Remove CONFIG_DRM_LEGACY from Kconfig. Nothing depends on the option.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/Kconfig | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index cdbc56e076498..5150c8699a8b5 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -407,27 +407,6 @@ config DRM_HYPERV
If M is selected the module will be called hyperv_drm.
-# Keep legacy drivers last
-
-menuconfig DRM_LEGACY
- bool "Enable legacy drivers (DANGEROUS)"
- depends on DRM && MMU
- help
- Enable legacy DRI1 drivers. Those drivers expose unsafe and dangerous
- APIs to user-space, which can be used to circumvent access
- restrictions and other security measures. For backwards compatibility
- those drivers are still available, but their use is highly
- inadvisable and might harm your system.
-
- You are recommended to use the safe modeset-only drivers instead, and
- perform 3D emulation in user-space.
-
- Unless you have strong reasons to go rogue, say "N".
-
-if DRM_LEGACY
-# leave here to list legacy drivers
-endif # DRM_LEGACY
-
config DRM_EXPORT_FOR_TESTS
bool
--
2.42.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [Intel-gfx] [PATCH 04/14] drm/i915: Include <drm/drm_auth.h>
2023-11-22 12:09 ` Thomas Zimmermann
@ 2023-11-22 18:14 ` Jani Nikula
-1 siblings, 0 replies; 39+ messages in thread
From: Jani Nikula @ 2023-11-22 18:14 UTC (permalink / raw)
To: Thomas Zimmermann, airlied, daniel, maarten.lankhorst, mripard,
cai.huoqing
Cc: intel-gfx, dri-devel, Thomas Zimmermann, Rodrigo Vivi
On Wed, 22 Nov 2023, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
> which will be removed. Include drm_auth.h directly.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: intel-gfx@lists.freedesktop.org
Acked-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index b1aa62dfb155d..81a57dd52dfda 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -9,6 +9,7 @@
> #include <linux/sync_file.h>
> #include <linux/uaccess.h>
>
> +#include <drm/drm_auth.h>
> #include <drm/drm_syncobj.h>
>
> #include "display/intel_frontbuffer.h"
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 04/14] drm/i915: Include <drm/drm_auth.h>
@ 2023-11-22 18:14 ` Jani Nikula
0 siblings, 0 replies; 39+ messages in thread
From: Jani Nikula @ 2023-11-22 18:14 UTC (permalink / raw)
To: Thomas Zimmermann, airlied, daniel, maarten.lankhorst, mripard,
cai.huoqing
Cc: Tvrtko Ursulin, intel-gfx, dri-devel, Thomas Zimmermann,
Rodrigo Vivi
On Wed, 22 Nov 2023, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
> which will be removed. Include drm_auth.h directly.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: intel-gfx@lists.freedesktop.org
Acked-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index b1aa62dfb155d..81a57dd52dfda 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -9,6 +9,7 @@
> #include <linux/sync_file.h>
> #include <linux/uaccess.h>
>
> +#include <drm/drm_auth.h>
> #include <drm/drm_syncobj.h>
>
> #include "display/intel_frontbuffer.h"
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h>
2023-11-22 12:09 ` [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h> Thomas Zimmermann
@ 2023-11-27 21:00 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:00 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: dri-devel, Pan, Xinhui, maarten.lankhorst, mripard, cai.huoqing,
amd-gfx, daniel, Alex Deucher, airlied, Christian König
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Including <drm/drm_legacy.h> is not required by radeon.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_drv.h | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
> index 34a1c73d3938f..02a65971d140d 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.h
> +++ b/drivers/gpu/drm/radeon/radeon_drv.h
> @@ -33,7 +33,6 @@
>
> #include <linux/firmware.h>
> #include <linux/platform_device.h>
> -#include <drm/drm_legacy.h>
>
> #include "radeon_family.h"
>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h>
@ 2023-11-27 21:00 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:00 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: dri-devel, Pan, Xinhui, mripard, cai.huoqing, amd-gfx,
Alex Deucher, Christian König
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Including <drm/drm_legacy.h> is not required by radeon.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_drv.h | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
> index 34a1c73d3938f..02a65971d140d 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.h
> +++ b/drivers/gpu/drm/radeon/radeon_drv.h
> @@ -33,7 +33,6 @@
>
> #include <linux/firmware.h>
> #include <linux/platform_device.h>
> -#include <drm/drm_legacy.h>
>
> #include "radeon_family.h"
>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 02/14] drm: Fix TODO list mentioning non-KMS drivers
2023-11-22 12:09 ` Thomas Zimmermann
@ 2023-11-27 21:02 ` Alex Deucher
-1 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:02 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing,
Jonathan Corbet, Daniel Vetter, linux-doc, stable, dri-devel,
Dave Airlie
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Non-KMS drivers have been removed from DRM. Update the TODO list
> accordingly.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
> Cc: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.3+
> Cc: linux-doc@vger.kernel.org
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> Documentation/gpu/todo.rst | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index b62c7fa0c2bcc..3bdb8787960be 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -337,8 +337,8 @@ connector register/unregister fixes
>
> Level: Intermediate
>
> -Remove load/unload callbacks from all non-DRIVER_LEGACY drivers
> ----------------------------------------------------------------
> +Remove load/unload callbacks
> +----------------------------
>
> The load/unload callbacks in struct &drm_driver are very much midlayers, plus
> for historical reasons they get the ordering wrong (and we can't fix that)
> @@ -347,8 +347,7 @@ between setting up the &drm_driver structure and calling drm_dev_register().
> - Rework drivers to no longer use the load/unload callbacks, directly coding the
> load/unload sequence into the driver's probe function.
>
> -- Once all non-DRIVER_LEGACY drivers are converted, disallow the load/unload
> - callbacks for all modern drivers.
> +- Once all drivers are converted, remove the load/unload callbacks.
>
> Contact: Daniel Vetter
>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 02/14] drm: Fix TODO list mentioning non-KMS drivers
@ 2023-11-27 21:02 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:02 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Jonathan Corbet, Daniel Vetter, dri-devel, linux-doc, mripard,
cai.huoqing, stable, Dave Airlie
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Non-KMS drivers have been removed from DRM. Update the TODO list
> accordingly.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
> Cc: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.3+
> Cc: linux-doc@vger.kernel.org
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> Documentation/gpu/todo.rst | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index b62c7fa0c2bcc..3bdb8787960be 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -337,8 +337,8 @@ connector register/unregister fixes
>
> Level: Intermediate
>
> -Remove load/unload callbacks from all non-DRIVER_LEGACY drivers
> ----------------------------------------------------------------
> +Remove load/unload callbacks
> +----------------------------
>
> The load/unload callbacks in struct &drm_driver are very much midlayers, plus
> for historical reasons they get the ordering wrong (and we can't fix that)
> @@ -347,8 +347,7 @@ between setting up the &drm_driver structure and calling drm_dev_register().
> - Rework drivers to no longer use the load/unload callbacks, directly coding the
> load/unload sequence into the driver's probe function.
>
> -- Once all non-DRIVER_LEGACY drivers are converted, disallow the load/unload
> - callbacks for all modern drivers.
> +- Once all drivers are converted, remove the load/unload callbacks.
>
> Contact: Daniel Vetter
>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs
2023-11-22 12:09 ` Thomas Zimmermann
@ 2023-11-27 21:03 ` Alex Deucher
-1 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:03 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing,
Daniel Vetter, stable, dri-devel, Dave Airlie
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> DRM drivers for user-space modesetting have been removed. Do not
> select the respective options in the default configs.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
> Cc: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.3+
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> arch/powerpc/configs/pmac32_defconfig | 2 --
> arch/powerpc/configs/ppc6xx_defconfig | 7 -------
> 2 files changed, 9 deletions(-)
>
> diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
> index 57ded82c28409..e41e7affd2482 100644
> --- a/arch/powerpc/configs/pmac32_defconfig
> +++ b/arch/powerpc/configs/pmac32_defconfig
> @@ -188,8 +188,6 @@ CONFIG_AGP=m
> CONFIG_AGP_UNINORTH=m
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_R128=m
> CONFIG_FB=y
> CONFIG_FB_OF=y
> CONFIG_FB_CONTROL=y
> diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
> index f279703425d45..e680cd086f0e8 100644
> --- a/arch/powerpc/configs/ppc6xx_defconfig
> +++ b/arch/powerpc/configs/ppc6xx_defconfig
> @@ -678,13 +678,6 @@ CONFIG_AGP=y
> CONFIG_AGP_UNINORTH=y
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_TDFX=m
> -CONFIG_DRM_R128=m
> -CONFIG_DRM_MGA=m
> -CONFIG_DRM_SIS=m
> -CONFIG_DRM_VIA=m
> -CONFIG_DRM_SAVAGE=m
> CONFIG_FB=y
> CONFIG_FB_CIRRUS=m
> CONFIG_FB_OF=y
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs
@ 2023-11-27 21:03 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:03 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Daniel Vetter, dri-devel, mripard, cai.huoqing, stable,
Dave Airlie
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> DRM drivers for user-space modesetting have been removed. Do not
> select the respective options in the default configs.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
> Cc: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.3+
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> arch/powerpc/configs/pmac32_defconfig | 2 --
> arch/powerpc/configs/ppc6xx_defconfig | 7 -------
> 2 files changed, 9 deletions(-)
>
> diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
> index 57ded82c28409..e41e7affd2482 100644
> --- a/arch/powerpc/configs/pmac32_defconfig
> +++ b/arch/powerpc/configs/pmac32_defconfig
> @@ -188,8 +188,6 @@ CONFIG_AGP=m
> CONFIG_AGP_UNINORTH=m
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_R128=m
> CONFIG_FB=y
> CONFIG_FB_OF=y
> CONFIG_FB_CONTROL=y
> diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
> index f279703425d45..e680cd086f0e8 100644
> --- a/arch/powerpc/configs/ppc6xx_defconfig
> +++ b/arch/powerpc/configs/ppc6xx_defconfig
> @@ -678,13 +678,6 @@ CONFIG_AGP=y
> CONFIG_AGP_UNINORTH=y
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_TDFX=m
> -CONFIG_DRM_R128=m
> -CONFIG_DRM_MGA=m
> -CONFIG_DRM_SIS=m
> -CONFIG_DRM_VIA=m
> -CONFIG_DRM_SAVAGE=m
> CONFIG_FB=y
> CONFIG_FB_CIRRUS=m
> CONFIG_FB_OF=y
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 03/14] drm: Include <drm/drm_auth.h>
2023-11-22 12:09 ` [PATCH 03/14] drm: Include <drm/drm_auth.h> Thomas Zimmermann
@ 2023-11-27 21:03 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:03 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
> which will be removed. Include drm_auth.h directly.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/drm_pci.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 39d35fc3a43bc..67907dd427214 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -29,6 +29,7 @@
> #include <linux/pci.h>
> #include <linux/slab.h>
>
> +#include <drm/drm_auth.h>
> #include <drm/drm.h>
> #include <drm/drm_drv.h>
> #include <drm/drm_print.h>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 05/14] accel: Include <drm/drm_auth.h>
2023-11-22 12:09 ` [PATCH 05/14] accel: " Thomas Zimmermann
@ 2023-11-27 21:03 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:03 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: Oded Gabbay, mripard, cai.huoqing, dri-devel
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> One of the source files includes <drm/drm_auth.h> via <drm/drm_legacy.h>,
> which will be removed. Include drm_auth.h directly.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Oded Gabbay <ogabbay@kernel.org>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/accel/drm_accel.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/accel/drm_accel.c b/drivers/accel/drm_accel.c
> index 294b572a9c331..24cac4c0274bb 100644
> --- a/drivers/accel/drm_accel.c
> +++ b/drivers/accel/drm_accel.c
> @@ -11,6 +11,7 @@
> #include <linux/idr.h>
>
> #include <drm/drm_accel.h>
> +#include <drm/drm_auth.h>
> #include <drm/drm_debugfs.h>
> #include <drm/drm_drv.h>
> #include <drm/drm_file.h>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 08/14] drm: Remove entry points for legacy ioctls
2023-11-22 12:09 ` [PATCH 08/14] drm: Remove entry points for legacy ioctls Thomas Zimmermann
@ 2023-11-27 21:04 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:04 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> DRM drivers with user-space mode setting have been removed in Linux
> v6.3. [1] Now remove the ioctl entry points for these drivers. Invoking
> any of the ioctl ops will unconditionally return -EINVAL to user space.
> This has already been the behavior for kernels without CONFIG_DRM_LEGACY
> set.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Link: https://patchwork.freedesktop.org/series/111602/ # [1]
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/drm_ioc32.c | 610 ------------------------------------
> drivers/gpu/drm/drm_ioctl.c | 57 ----
> 2 files changed, 667 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
> index c0163cb076ad8..910cadf14756e 100644
> --- a/drivers/gpu/drm/drm_ioc32.c
> +++ b/drivers/gpu/drm/drm_ioc32.c
> @@ -37,7 +37,6 @@
>
> #include "drm_crtc_internal.h"
> #include "drm_internal.h"
> -#include "drm_legacy.h"
>
> #define DRM_IOCTL_VERSION32 DRM_IOWR(0x00, drm_version32_t)
> #define DRM_IOCTL_GET_UNIQUE32 DRM_IOWR(0x01, drm_unique32_t)
> @@ -164,92 +163,6 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
> return -EINVAL;
> }
>
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> -typedef struct drm_map32 {
> - u32 offset; /* Requested physical address (0 for SAREA) */
> - u32 size; /* Requested physical size (bytes) */
> - enum drm_map_type type; /* Type of memory to map */
> - enum drm_map_flags flags; /* Flags */
> - u32 handle; /* User-space: "Handle" to pass to mmap() */
> - int mtrr; /* MTRR slot used */
> -} drm_map32_t;
> -
> -static int compat_drm_getmap(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_map32_t __user *argp = (void __user *)arg;
> - drm_map32_t m32;
> - struct drm_map map;
> - int err;
> -
> - if (copy_from_user(&m32, argp, sizeof(m32)))
> - return -EFAULT;
> -
> - map.offset = m32.offset;
> - err = drm_ioctl_kernel(file, drm_legacy_getmap_ioctl, &map, 0);
> - if (err)
> - return err;
> -
> - m32.offset = map.offset;
> - m32.size = map.size;
> - m32.type = map.type;
> - m32.flags = map.flags;
> - m32.handle = ptr_to_compat((void __user *)map.handle);
> - m32.mtrr = map.mtrr;
> - if (copy_to_user(argp, &m32, sizeof(m32)))
> - return -EFAULT;
> - return 0;
> -
> -}
> -
> -static int compat_drm_addmap(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_map32_t __user *argp = (void __user *)arg;
> - drm_map32_t m32;
> - struct drm_map map;
> - int err;
> -
> - if (copy_from_user(&m32, argp, sizeof(m32)))
> - return -EFAULT;
> -
> - map.offset = m32.offset;
> - map.size = m32.size;
> - map.type = m32.type;
> - map.flags = m32.flags;
> -
> - err = drm_ioctl_kernel(file, drm_legacy_addmap_ioctl, &map,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> - if (err)
> - return err;
> -
> - m32.offset = map.offset;
> - m32.mtrr = map.mtrr;
> - m32.handle = ptr_to_compat((void __user *)map.handle);
> - if (map.handle != compat_ptr(m32.handle))
> - pr_err_ratelimited("compat_drm_addmap truncated handle %p for type %d offset %x\n",
> - map.handle, m32.type, m32.offset);
> -
> - if (copy_to_user(argp, &m32, sizeof(m32)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -static int compat_drm_rmmap(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_map32_t __user *argp = (void __user *)arg;
> - struct drm_map map;
> - u32 handle;
> -
> - if (get_user(handle, &argp->handle))
> - return -EFAULT;
> - map.handle = compat_ptr(handle);
> - return drm_ioctl_kernel(file, drm_legacy_rmmap_ioctl, &map, DRM_AUTH);
> -}
> -#endif
> -
> typedef struct drm_client32 {
> int idx; /* Which client desired? */
> int auth; /* Is client authenticated? */
> @@ -309,501 +222,6 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
> return 0;
> }
>
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> -typedef struct drm_buf_desc32 {
> - int count; /* Number of buffers of this size */
> - int size; /* Size in bytes */
> - int low_mark; /* Low water mark */
> - int high_mark; /* High water mark */
> - int flags;
> - u32 agp_start; /* Start address in the AGP aperture */
> -} drm_buf_desc32_t;
> -
> -static int compat_drm_addbufs(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_buf_desc32_t __user *argp = (void __user *)arg;
> - drm_buf_desc32_t desc32;
> - struct drm_buf_desc desc;
> - int err;
> -
> - if (copy_from_user(&desc32, argp, sizeof(drm_buf_desc32_t)))
> - return -EFAULT;
> -
> - desc = (struct drm_buf_desc){
> - desc32.count, desc32.size, desc32.low_mark, desc32.high_mark,
> - desc32.flags, desc32.agp_start
> - };
> -
> - err = drm_ioctl_kernel(file, drm_legacy_addbufs, &desc,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> - if (err)
> - return err;
> -
> - desc32 = (drm_buf_desc32_t){
> - desc.count, desc.size, desc.low_mark, desc.high_mark,
> - desc.flags, desc.agp_start
> - };
> - if (copy_to_user(argp, &desc32, sizeof(drm_buf_desc32_t)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -static int compat_drm_markbufs(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_buf_desc32_t b32;
> - drm_buf_desc32_t __user *argp = (void __user *)arg;
> - struct drm_buf_desc buf;
> -
> - if (copy_from_user(&b32, argp, sizeof(b32)))
> - return -EFAULT;
> -
> - buf.size = b32.size;
> - buf.low_mark = b32.low_mark;
> - buf.high_mark = b32.high_mark;
> -
> - return drm_ioctl_kernel(file, drm_legacy_markbufs, &buf,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -
> -typedef struct drm_buf_info32 {
> - int count; /**< Entries in list */
> - u32 list;
> -} drm_buf_info32_t;
> -
> -static int copy_one_buf32(void *data, int count, struct drm_buf_entry *from)
> -{
> - drm_buf_info32_t *request = data;
> - drm_buf_desc32_t __user *to = compat_ptr(request->list);
> - drm_buf_desc32_t v = {.count = from->buf_count,
> - .size = from->buf_size,
> - .low_mark = from->low_mark,
> - .high_mark = from->high_mark};
> -
> - if (copy_to_user(to + count, &v, offsetof(drm_buf_desc32_t, flags)))
> - return -EFAULT;
> - return 0;
> -}
> -
> -static int drm_legacy_infobufs32(struct drm_device *dev, void *data,
> - struct drm_file *file_priv)
> -{
> - drm_buf_info32_t *request = data;
> -
> - return __drm_legacy_infobufs(dev, data, &request->count, copy_one_buf32);
> -}
> -
> -static int compat_drm_infobufs(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_buf_info32_t req32;
> - drm_buf_info32_t __user *argp = (void __user *)arg;
> - int err;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> -
> - if (req32.count < 0)
> - req32.count = 0;
> -
> - err = drm_ioctl_kernel(file, drm_legacy_infobufs32, &req32, DRM_AUTH);
> - if (err)
> - return err;
> -
> - if (put_user(req32.count, &argp->count))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -typedef struct drm_buf_pub32 {
> - int idx; /**< Index into the master buffer list */
> - int total; /**< Buffer size */
> - int used; /**< Amount of buffer in use (for DMA) */
> - u32 address; /**< Address of buffer */
> -} drm_buf_pub32_t;
> -
> -typedef struct drm_buf_map32 {
> - int count; /**< Length of the buffer list */
> - u32 virtual; /**< Mmap'd area in user-virtual */
> - u32 list; /**< Buffer information */
> -} drm_buf_map32_t;
> -
> -static int map_one_buf32(void *data, int idx, unsigned long virtual,
> - struct drm_buf *buf)
> -{
> - drm_buf_map32_t *request = data;
> - drm_buf_pub32_t __user *to = compat_ptr(request->list) + idx;
> - drm_buf_pub32_t v;
> -
> - v.idx = buf->idx;
> - v.total = buf->total;
> - v.used = 0;
> - v.address = virtual + buf->offset;
> - if (copy_to_user(to, &v, sizeof(v)))
> - return -EFAULT;
> - return 0;
> -}
> -
> -static int drm_legacy_mapbufs32(struct drm_device *dev, void *data,
> - struct drm_file *file_priv)
> -{
> - drm_buf_map32_t *request = data;
> - void __user *v;
> - int err = __drm_legacy_mapbufs(dev, data, &request->count,
> - &v, map_one_buf32,
> - file_priv);
> - request->virtual = ptr_to_compat(v);
> - return err;
> -}
> -
> -static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_buf_map32_t __user *argp = (void __user *)arg;
> - drm_buf_map32_t req32;
> - int err;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> - if (req32.count < 0)
> - return -EINVAL;
> -
> - err = drm_ioctl_kernel(file, drm_legacy_mapbufs32, &req32, DRM_AUTH);
> - if (err)
> - return err;
> -
> - if (put_user(req32.count, &argp->count)
> - || put_user(req32.virtual, &argp->virtual))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -typedef struct drm_buf_free32 {
> - int count;
> - u32 list;
> -} drm_buf_free32_t;
> -
> -static int compat_drm_freebufs(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_buf_free32_t req32;
> - struct drm_buf_free request;
> - drm_buf_free32_t __user *argp = (void __user *)arg;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> -
> - request.count = req32.count;
> - request.list = compat_ptr(req32.list);
> - return drm_ioctl_kernel(file, drm_legacy_freebufs, &request, DRM_AUTH);
> -}
> -
> -typedef struct drm_ctx_priv_map32 {
> - unsigned int ctx_id; /**< Context requesting private mapping */
> - u32 handle; /**< Handle of map */
> -} drm_ctx_priv_map32_t;
> -
> -static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_ctx_priv_map32_t req32;
> - struct drm_ctx_priv_map request;
> - drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> -
> - request.ctx_id = req32.ctx_id;
> - request.handle = compat_ptr(req32.handle);
> - return drm_ioctl_kernel(file, drm_legacy_setsareactx, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -
> -static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - struct drm_ctx_priv_map req;
> - drm_ctx_priv_map32_t req32;
> - drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
> - int err;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> -
> - req.ctx_id = req32.ctx_id;
> - err = drm_ioctl_kernel(file, drm_legacy_getsareactx, &req, DRM_AUTH);
> - if (err)
> - return err;
> -
> - req32.handle = ptr_to_compat((void __user *)req.handle);
> - if (copy_to_user(argp, &req32, sizeof(req32)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -typedef struct drm_ctx_res32 {
> - int count;
> - u32 contexts;
> -} drm_ctx_res32_t;
> -
> -static int compat_drm_resctx(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_ctx_res32_t __user *argp = (void __user *)arg;
> - drm_ctx_res32_t res32;
> - struct drm_ctx_res res;
> - int err;
> -
> - if (copy_from_user(&res32, argp, sizeof(res32)))
> - return -EFAULT;
> -
> - res.count = res32.count;
> - res.contexts = compat_ptr(res32.contexts);
> - err = drm_ioctl_kernel(file, drm_legacy_resctx, &res, DRM_AUTH);
> - if (err)
> - return err;
> -
> - res32.count = res.count;
> - if (copy_to_user(argp, &res32, sizeof(res32)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -typedef struct drm_dma32 {
> - int context; /**< Context handle */
> - int send_count; /**< Number of buffers to send */
> - u32 send_indices; /**< List of handles to buffers */
> - u32 send_sizes; /**< Lengths of data to send */
> - enum drm_dma_flags flags; /**< Flags */
> - int request_count; /**< Number of buffers requested */
> - int request_size; /**< Desired size for buffers */
> - u32 request_indices; /**< Buffer information */
> - u32 request_sizes;
> - int granted_count; /**< Number of buffers granted */
> -} drm_dma32_t;
> -
> -static int compat_drm_dma(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_dma32_t d32;
> - drm_dma32_t __user *argp = (void __user *)arg;
> - struct drm_dma d;
> - int err;
> -
> - if (copy_from_user(&d32, argp, sizeof(d32)))
> - return -EFAULT;
> -
> - d.context = d32.context;
> - d.send_count = d32.send_count;
> - d.send_indices = compat_ptr(d32.send_indices);
> - d.send_sizes = compat_ptr(d32.send_sizes);
> - d.flags = d32.flags;
> - d.request_count = d32.request_count;
> - d.request_indices = compat_ptr(d32.request_indices);
> - d.request_sizes = compat_ptr(d32.request_sizes);
> - err = drm_ioctl_kernel(file, drm_legacy_dma_ioctl, &d, DRM_AUTH);
> - if (err)
> - return err;
> -
> - if (put_user(d.request_size, &argp->request_size)
> - || put_user(d.granted_count, &argp->granted_count))
> - return -EFAULT;
> -
> - return 0;
> -}
> -#endif
> -
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> -#if IS_ENABLED(CONFIG_AGP)
> -typedef struct drm_agp_mode32 {
> - u32 mode; /**< AGP mode */
> -} drm_agp_mode32_t;
> -
> -static int compat_drm_agp_enable(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_agp_mode32_t __user *argp = (void __user *)arg;
> - struct drm_agp_mode mode;
> -
> - if (get_user(mode.mode, &argp->mode))
> - return -EFAULT;
> -
> - return drm_ioctl_kernel(file, drm_legacy_agp_enable_ioctl, &mode,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -
> -typedef struct drm_agp_info32 {
> - int agp_version_major;
> - int agp_version_minor;
> - u32 mode;
> - u32 aperture_base; /* physical address */
> - u32 aperture_size; /* bytes */
> - u32 memory_allowed; /* bytes */
> - u32 memory_used;
> -
> - /* PCI information */
> - unsigned short id_vendor;
> - unsigned short id_device;
> -} drm_agp_info32_t;
> -
> -static int compat_drm_agp_info(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_agp_info32_t __user *argp = (void __user *)arg;
> - drm_agp_info32_t i32;
> - struct drm_agp_info info;
> - int err;
> -
> - err = drm_ioctl_kernel(file, drm_legacy_agp_info_ioctl, &info, DRM_AUTH);
> - if (err)
> - return err;
> -
> - i32.agp_version_major = info.agp_version_major;
> - i32.agp_version_minor = info.agp_version_minor;
> - i32.mode = info.mode;
> - i32.aperture_base = info.aperture_base;
> - i32.aperture_size = info.aperture_size;
> - i32.memory_allowed = info.memory_allowed;
> - i32.memory_used = info.memory_used;
> - i32.id_vendor = info.id_vendor;
> - i32.id_device = info.id_device;
> - if (copy_to_user(argp, &i32, sizeof(i32)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -typedef struct drm_agp_buffer32 {
> - u32 size; /**< In bytes -- will round to page boundary */
> - u32 handle; /**< Used for binding / unbinding */
> - u32 type; /**< Type of memory to allocate */
> - u32 physical; /**< Physical used by i810 */
> -} drm_agp_buffer32_t;
> -
> -static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_agp_buffer32_t __user *argp = (void __user *)arg;
> - drm_agp_buffer32_t req32;
> - struct drm_agp_buffer request;
> - int err;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> -
> - request.size = req32.size;
> - request.type = req32.type;
> - err = drm_ioctl_kernel(file, drm_legacy_agp_alloc_ioctl, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> - if (err)
> - return err;
> -
> - req32.handle = request.handle;
> - req32.physical = request.physical;
> - if (copy_to_user(argp, &req32, sizeof(req32))) {
> - drm_ioctl_kernel(file, drm_legacy_agp_free_ioctl, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> - return -EFAULT;
> - }
> -
> - return 0;
> -}
> -
> -static int compat_drm_agp_free(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_agp_buffer32_t __user *argp = (void __user *)arg;
> - struct drm_agp_buffer request;
> -
> - if (get_user(request.handle, &argp->handle))
> - return -EFAULT;
> -
> - return drm_ioctl_kernel(file, drm_legacy_agp_free_ioctl, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -
> -typedef struct drm_agp_binding32 {
> - u32 handle; /**< From drm_agp_buffer */
> - u32 offset; /**< In bytes -- will round to page boundary */
> -} drm_agp_binding32_t;
> -
> -static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_agp_binding32_t __user *argp = (void __user *)arg;
> - drm_agp_binding32_t req32;
> - struct drm_agp_binding request;
> -
> - if (copy_from_user(&req32, argp, sizeof(req32)))
> - return -EFAULT;
> -
> - request.handle = req32.handle;
> - request.offset = req32.offset;
> - return drm_ioctl_kernel(file, drm_legacy_agp_bind_ioctl, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -
> -static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_agp_binding32_t __user *argp = (void __user *)arg;
> - struct drm_agp_binding request;
> -
> - if (get_user(request.handle, &argp->handle))
> - return -EFAULT;
> -
> - return drm_ioctl_kernel(file, drm_legacy_agp_unbind_ioctl, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -#endif /* CONFIG_AGP */
> -
> -typedef struct drm_scatter_gather32 {
> - u32 size; /**< In bytes -- will round to page boundary */
> - u32 handle; /**< Used for mapping / unmapping */
> -} drm_scatter_gather32_t;
> -
> -static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_scatter_gather32_t __user *argp = (void __user *)arg;
> - struct drm_scatter_gather request;
> - int err;
> -
> - if (get_user(request.size, &argp->size))
> - return -EFAULT;
> -
> - err = drm_ioctl_kernel(file, drm_legacy_sg_alloc, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> - if (err)
> - return err;
> -
> - /* XXX not sure about the handle conversion here... */
> - if (put_user(request.handle >> PAGE_SHIFT, &argp->handle))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -static int compat_drm_sg_free(struct file *file, unsigned int cmd,
> - unsigned long arg)
> -{
> - drm_scatter_gather32_t __user *argp = (void __user *)arg;
> - struct drm_scatter_gather request;
> - unsigned long x;
> -
> - if (get_user(x, &argp->handle))
> - return -EFAULT;
> - request.handle = x << PAGE_SHIFT;
> - return drm_ioctl_kernel(file, drm_legacy_sg_free, &request,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY);
> -}
> -#endif
> #if defined(CONFIG_X86)
> typedef struct drm_update_draw32 {
> drm_drawable_t handle;
> @@ -915,37 +333,9 @@ static struct {
> #define DRM_IOCTL32_DEF(n, f) [DRM_IOCTL_NR(n##32)] = {.fn = f, .name = #n}
> DRM_IOCTL32_DEF(DRM_IOCTL_VERSION, compat_drm_version),
> DRM_IOCTL32_DEF(DRM_IOCTL_GET_UNIQUE, compat_drm_getunique),
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> - DRM_IOCTL32_DEF(DRM_IOCTL_GET_MAP, compat_drm_getmap),
> -#endif
> DRM_IOCTL32_DEF(DRM_IOCTL_GET_CLIENT, compat_drm_getclient),
> DRM_IOCTL32_DEF(DRM_IOCTL_GET_STATS, compat_drm_getstats),
> DRM_IOCTL32_DEF(DRM_IOCTL_SET_UNIQUE, compat_drm_setunique),
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> - DRM_IOCTL32_DEF(DRM_IOCTL_ADD_MAP, compat_drm_addmap),
> - DRM_IOCTL32_DEF(DRM_IOCTL_ADD_BUFS, compat_drm_addbufs),
> - DRM_IOCTL32_DEF(DRM_IOCTL_MARK_BUFS, compat_drm_markbufs),
> - DRM_IOCTL32_DEF(DRM_IOCTL_INFO_BUFS, compat_drm_infobufs),
> - DRM_IOCTL32_DEF(DRM_IOCTL_MAP_BUFS, compat_drm_mapbufs),
> - DRM_IOCTL32_DEF(DRM_IOCTL_FREE_BUFS, compat_drm_freebufs),
> - DRM_IOCTL32_DEF(DRM_IOCTL_RM_MAP, compat_drm_rmmap),
> - DRM_IOCTL32_DEF(DRM_IOCTL_SET_SAREA_CTX, compat_drm_setsareactx),
> - DRM_IOCTL32_DEF(DRM_IOCTL_GET_SAREA_CTX, compat_drm_getsareactx),
> - DRM_IOCTL32_DEF(DRM_IOCTL_RES_CTX, compat_drm_resctx),
> - DRM_IOCTL32_DEF(DRM_IOCTL_DMA, compat_drm_dma),
> -#if IS_ENABLED(CONFIG_AGP)
> - DRM_IOCTL32_DEF(DRM_IOCTL_AGP_ENABLE, compat_drm_agp_enable),
> - DRM_IOCTL32_DEF(DRM_IOCTL_AGP_INFO, compat_drm_agp_info),
> - DRM_IOCTL32_DEF(DRM_IOCTL_AGP_ALLOC, compat_drm_agp_alloc),
> - DRM_IOCTL32_DEF(DRM_IOCTL_AGP_FREE, compat_drm_agp_free),
> - DRM_IOCTL32_DEF(DRM_IOCTL_AGP_BIND, compat_drm_agp_bind),
> - DRM_IOCTL32_DEF(DRM_IOCTL_AGP_UNBIND, compat_drm_agp_unbind),
> -#endif
> -#endif
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> - DRM_IOCTL32_DEF(DRM_IOCTL_SG_ALLOC, compat_drm_sg_alloc),
> - DRM_IOCTL32_DEF(DRM_IOCTL_SG_FREE, compat_drm_sg_free),
> -#endif
> #if defined(CONFIG_X86)
> DRM_IOCTL32_DEF(DRM_IOCTL_UPDATE_DRAW, compat_drm_update_draw),
> #endif
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 44fda68c28aeb..e6c32f76c7452 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -42,7 +42,6 @@
>
> #include "drm_crtc_internal.h"
> #include "drm_internal.h"
> -#include "drm_legacy.h"
>
> /**
> * DOC: getunique and setversion story
> @@ -559,21 +558,11 @@ static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
> .name = #ioctl \
> }
>
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> -#define DRM_LEGACY_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(ioctl, _func, _flags)
> -#else
> -#define DRM_LEGACY_IOCTL_DEF(ioctl, _func, _flags) DRM_IOCTL_DEF(ioctl, drm_invalid_op, _flags)
> -#endif
> -
> /* Ioctl table */
> static const struct drm_ioctl_desc drm_ioctls[] = {
> DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_RENDER_ALLOW),
> DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
> DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_legacy_irq_by_busid,
> - DRM_MASTER|DRM_ROOT_ONLY),
> -
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, 0),
>
> DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0),
> DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0),
> @@ -586,60 +575,14 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
> DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_MASTER),
>
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_legacy_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_legacy_rmmap_ioctl, DRM_AUTH),
> -
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_legacy_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_legacy_getsareactx, DRM_AUTH),
> -
> DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, 0),
> DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, 0),
>
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_legacy_addctx, DRM_AUTH|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_legacy_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_legacy_getctx, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_legacy_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_legacy_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_legacy_resctx, DRM_AUTH),
> -
> DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
>
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_LOCK, drm_legacy_lock, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_legacy_unlock, DRM_AUTH),
> -
> DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
>
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_legacy_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_legacy_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_legacy_infobufs, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_legacy_mapbufs, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_legacy_freebufs, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_DMA, drm_legacy_dma_ioctl, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_legacy_irq_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> -
> -#if IS_ENABLED(CONFIG_AGP)
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_legacy_agp_acquire_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_legacy_agp_release_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_legacy_agp_enable_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_legacy_agp_info_ioctl, DRM_AUTH),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_legacy_agp_alloc_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_legacy_agp_free_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_legacy_agp_bind_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_legacy_agp_unbind_ioctl,
> - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> -#endif
> -
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_legacy_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> - DRM_LEGACY_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_legacy_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
> -
> DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
>
> DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_legacy_modeset_ctl_ioctl, 0),
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl
2023-11-22 12:09 ` [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl Thomas Zimmermann
@ 2023-11-27 21:05 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:05 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> DRM drivers with user-space mode setting have been removed in Linux
> v6.3. [1] Now remove the ioctl entry points for these drivers. Invoking
> any of the ioctl ops will unconditionally return -EINVAL to user space.
>
> Invoking DRM_IOCTL_MODESET_CTL is different from the other legacy
> ioctl ops as it returns 0 even without CONFIG_DRM_LEGACY set. From the
> original commit 29935554b384 ("drm: Disallow DRM_IOCTL_MODESET_CTL for
> KMS drivers") it is not apparent how or why the operation differs from
> the others. It is likely just an oversight in commit 61ae227032e7
> ("drm: allow removal of legacy codepaths (v4.1)"), which allowed
> disabling leagacy ioctls in the first place. Still keep this removal
> separate from the other ioctls to allow an easy revert, if necessary.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Link: https://patchwork.freedesktop.org/series/111602/ # [1]
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/drm_internal.h | 2 -
> drivers/gpu/drm/drm_ioctl.c | 2 -
> drivers/gpu/drm/drm_vblank.c | 82 ----------------------------------
> 3 files changed, 86 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index b12c463bc4605..a538a48c7d952 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -117,8 +117,6 @@ void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
> /* IOCTLS */
> int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
> struct drm_file *filp);
> -int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
> - struct drm_file *file_priv);
>
> /* drm_irq.c */
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index e6c32f76c7452..9c6326b908e74 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -585,8 +585,6 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
>
> DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
>
> - DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_legacy_modeset_ctl_ioctl, 0),
> -
> DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
>
> DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_RENDER_ALLOW),
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 877e2067534fa..a11f164b2384f 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -1574,88 +1574,6 @@ void drm_crtc_vblank_restore(struct drm_crtc *crtc)
> }
> EXPORT_SYMBOL(drm_crtc_vblank_restore);
>
> -static void drm_legacy_vblank_pre_modeset(struct drm_device *dev,
> - unsigned int pipe)
> -{
> - struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
> -
> - /* vblank is not initialized (IRQ not installed ?), or has been freed */
> - if (!drm_dev_has_vblank(dev))
> - return;
> -
> - if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
> - return;
> -
> - /*
> - * To avoid all the problems that might happen if interrupts
> - * were enabled/disabled around or between these calls, we just
> - * have the kernel take a reference on the CRTC (just once though
> - * to avoid corrupting the count if multiple, mismatch calls occur),
> - * so that interrupts remain enabled in the interim.
> - */
> - if (!vblank->inmodeset) {
> - vblank->inmodeset = 0x1;
> - if (drm_vblank_get(dev, pipe) == 0)
> - vblank->inmodeset |= 0x2;
> - }
> -}
> -
> -static void drm_legacy_vblank_post_modeset(struct drm_device *dev,
> - unsigned int pipe)
> -{
> - struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
> -
> - /* vblank is not initialized (IRQ not installed ?), or has been freed */
> - if (!drm_dev_has_vblank(dev))
> - return;
> -
> - if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
> - return;
> -
> - if (vblank->inmodeset) {
> - spin_lock_irq(&dev->vbl_lock);
> - drm_reset_vblank_timestamp(dev, pipe);
> - spin_unlock_irq(&dev->vbl_lock);
> -
> - if (vblank->inmodeset & 0x2)
> - drm_vblank_put(dev, pipe);
> -
> - vblank->inmodeset = 0;
> - }
> -}
> -
> -int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
> - struct drm_file *file_priv)
> -{
> - struct drm_modeset_ctl *modeset = data;
> - unsigned int pipe;
> -
> - /* If drm_vblank_init() hasn't been called yet, just no-op */
> - if (!drm_dev_has_vblank(dev))
> - return 0;
> -
> - /* KMS drivers handle this internally */
> - if (!drm_core_check_feature(dev, DRIVER_LEGACY))
> - return 0;
> -
> - pipe = modeset->crtc;
> - if (pipe >= dev->num_crtcs)
> - return -EINVAL;
> -
> - switch (modeset->cmd) {
> - case _DRM_PRE_MODESET:
> - drm_legacy_vblank_pre_modeset(dev, pipe);
> - break;
> - case _DRM_POST_MODESET:
> - drm_legacy_vblank_post_modeset(dev, pipe);
> - break;
> - default:
> - return -EINVAL;
> - }
> -
> - return 0;
> -}
> -
> static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
> u64 req_seq,
> union drm_wait_vblank *vblwait,
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 10/14] drm: Remove support for legacy drivers
2023-11-22 12:09 ` [PATCH 10/14] drm: Remove support for legacy drivers Thomas Zimmermann
@ 2023-11-27 21:05 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:05 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Remove all hooks and calls into code for user-space mode setting from
> the DRM core. Without the drivers and ioctl entry points, none of this
> is required any longer.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/drm_auth.c | 8 +----
> drivers/gpu/drm/drm_drv.c | 17 ----------
> drivers/gpu/drm/drm_file.c | 64 ++----------------------------------
> drivers/gpu/drm/drm_vblank.c | 19 -----------
> 4 files changed, 3 insertions(+), 105 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
> index 2ed2585ded378..252c105d614ff 100644
> --- a/drivers/gpu/drm/drm_auth.c
> +++ b/drivers/gpu/drm/drm_auth.c
> @@ -37,13 +37,12 @@
> #include <drm/drm_print.h>
>
> #include "drm_internal.h"
> -#include "drm_legacy.h"
>
> /**
> * DOC: master and authentication
> *
> * &struct drm_master is used to track groups of clients with open
> - * primary/legacy device nodes. For every &struct drm_file which has had at
> + * primary device nodes. For every &struct drm_file which has had at
> * least once successfully became the device master (either through the
> * SET_MASTER IOCTL, or implicitly through opening the primary device node when
> * no one else is the current master that time) there exists one &drm_master.
> @@ -139,7 +138,6 @@ struct drm_master *drm_master_create(struct drm_device *dev)
> return NULL;
>
> kref_init(&master->refcount);
> - drm_master_legacy_init(master);
> idr_init_base(&master->magic_map, 1);
> master->dev = dev;
>
> @@ -365,8 +363,6 @@ void drm_master_release(struct drm_file *file_priv)
> if (!drm_is_current_master_locked(file_priv))
> goto out;
>
> - drm_legacy_lock_master_cleanup(dev, master);
> -
> if (dev->master == file_priv->master)
> drm_drop_master(dev, file_priv);
> out:
> @@ -429,8 +425,6 @@ static void drm_master_destroy(struct kref *kref)
> if (drm_core_check_feature(dev, DRIVER_MODESET))
> drm_lease_destroy(master);
>
> - drm_legacy_master_rmmaps(dev, master);
> -
> idr_destroy(&master->magic_map);
> idr_destroy(&master->leases);
> idr_destroy(&master->lessee_idr);
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 535f16e7882e7..979366e68dbb8 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -48,7 +48,6 @@
>
> #include "drm_crtc_internal.h"
> #include "drm_internal.h"
> -#include "drm_legacy.h"
>
> MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
> MODULE_DESCRIPTION("DRM shared core routines");
> @@ -585,8 +584,6 @@ static void drm_fs_inode_free(struct inode *inode)
>
> static void drm_dev_init_release(struct drm_device *dev, void *res)
> {
> - drm_legacy_ctxbitmap_cleanup(dev);
> - drm_legacy_remove_map_hash(dev);
> drm_fs_inode_free(dev->anon_inode);
>
> put_device(dev->dev);
> @@ -597,7 +594,6 @@ static void drm_dev_init_release(struct drm_device *dev, void *res)
> mutex_destroy(&dev->clientlist_mutex);
> mutex_destroy(&dev->filelist_mutex);
> mutex_destroy(&dev->struct_mutex);
> - drm_legacy_destroy_members(dev);
> }
>
> static int drm_dev_init(struct drm_device *dev,
> @@ -632,7 +628,6 @@ static int drm_dev_init(struct drm_device *dev,
> return -EINVAL;
> }
>
> - drm_legacy_init_members(dev);
> INIT_LIST_HEAD(&dev->filelist);
> INIT_LIST_HEAD(&dev->filelist_internal);
> INIT_LIST_HEAD(&dev->clientlist);
> @@ -673,12 +668,6 @@ static int drm_dev_init(struct drm_device *dev,
> goto err;
> }
>
> - ret = drm_legacy_create_map_hash(dev);
> - if (ret)
> - goto err;
> -
> - drm_legacy_ctxbitmap_init(dev);
> -
> if (drm_core_check_feature(dev, DRIVER_GEM)) {
> ret = drm_gem_init(dev);
> if (ret) {
> @@ -990,9 +979,6 @@ EXPORT_SYMBOL(drm_dev_register);
> */
> void drm_dev_unregister(struct drm_device *dev)
> {
> - if (drm_core_check_feature(dev, DRIVER_LEGACY))
> - drm_lastclose(dev);
> -
> dev->registered = false;
>
> drm_client_dev_unregister(dev);
> @@ -1003,9 +989,6 @@ void drm_dev_unregister(struct drm_device *dev)
> if (dev->driver->unload)
> dev->driver->unload(dev);
>
> - drm_legacy_pci_agp_destroy(dev);
> - drm_legacy_rmmaps(dev);
> -
> remove_compat_control_link(dev);
> drm_minor_unregister(dev, DRM_MINOR_ACCEL);
> drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index 5ddaffd325865..987c1a5d1773b 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -47,21 +47,12 @@
>
> #include "drm_crtc_internal.h"
> #include "drm_internal.h"
> -#include "drm_legacy.h"
>
> /* from BKL pushdown */
> DEFINE_MUTEX(drm_global_mutex);
>
> bool drm_dev_needs_global_mutex(struct drm_device *dev)
> {
> - /*
> - * Legacy drivers rely on all kinds of BKL locking semantics, don't
> - * bother. They also still need BKL locking for their ioctls, so better
> - * safe than sorry.
> - */
> - if (drm_core_check_feature(dev, DRIVER_LEGACY))
> - return true;
> -
> /*
> * The deprecated ->load callback must be called after the driver is
> * already registered. This means such drivers rely on the BKL to make
> @@ -107,9 +98,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
> * drm_send_event() as the main starting points.
> *
> * The memory mapping implementation will vary depending on how the driver
> - * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
> - * function, modern drivers should use one of the provided memory-manager
> - * specific implementations. For GEM-based drivers this is drm_gem_mmap().
> + * manages memory. For GEM-based drivers this is drm_gem_mmap().
> *
> * No other file operations are supported by the DRM userspace API. Overall the
> * following is an example &file_operations structure::
> @@ -254,18 +243,6 @@ void drm_file_free(struct drm_file *file)
> (long)old_encode_dev(file->minor->kdev->devt),
> atomic_read(&dev->open_count));
>
> -#ifdef CONFIG_DRM_LEGACY
> - if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
> - dev->driver->preclose)
> - dev->driver->preclose(dev, file);
> -#endif
> -
> - if (drm_core_check_feature(dev, DRIVER_LEGACY))
> - drm_legacy_lock_release(dev, file->filp);
> -
> - if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
> - drm_legacy_reclaim_buffers(dev, file);
> -
> drm_events_release(file);
>
> if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> @@ -279,8 +256,6 @@ void drm_file_free(struct drm_file *file)
> if (drm_core_check_feature(dev, DRIVER_GEM))
> drm_gem_release(dev, file);
>
> - drm_legacy_ctxbitmap_flush(dev, file);
> -
> if (drm_is_primary_client(file))
> drm_master_release(file);
>
> @@ -367,29 +342,6 @@ int drm_open_helper(struct file *filp, struct drm_minor *minor)
> list_add(&priv->lhead, &dev->filelist);
> mutex_unlock(&dev->filelist_mutex);
>
> -#ifdef CONFIG_DRM_LEGACY
> -#ifdef __alpha__
> - /*
> - * Default the hose
> - */
> - if (!dev->hose) {
> - struct pci_dev *pci_dev;
> -
> - pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
> - if (pci_dev) {
> - dev->hose = pci_dev->sysdata;
> - pci_dev_put(pci_dev);
> - }
> - if (!dev->hose) {
> - struct pci_bus *b = list_entry(pci_root_buses.next,
> - struct pci_bus, node);
> - if (b)
> - dev->hose = b->sysdata;
> - }
> - }
> -#endif
> -#endif
> -
> return 0;
> }
>
> @@ -411,7 +363,6 @@ int drm_open(struct inode *inode, struct file *filp)
> struct drm_device *dev;
> struct drm_minor *minor;
> int retcode;
> - int need_setup = 0;
>
> minor = drm_minor_acquire(iminor(inode));
> if (IS_ERR(minor))
> @@ -421,8 +372,7 @@ int drm_open(struct inode *inode, struct file *filp)
> if (drm_dev_needs_global_mutex(dev))
> mutex_lock(&drm_global_mutex);
>
> - if (!atomic_fetch_inc(&dev->open_count))
> - need_setup = 1;
> + atomic_fetch_inc(&dev->open_count);
>
> /* share address_space across all char-devs of a single device */
> filp->f_mapping = dev->anon_inode->i_mapping;
> @@ -430,13 +380,6 @@ int drm_open(struct inode *inode, struct file *filp)
> retcode = drm_open_helper(filp, minor);
> if (retcode)
> goto err_undo;
> - if (need_setup) {
> - retcode = drm_legacy_setup(dev);
> - if (retcode) {
> - drm_close_helper(filp);
> - goto err_undo;
> - }
> - }
>
> if (drm_dev_needs_global_mutex(dev))
> mutex_unlock(&drm_global_mutex);
> @@ -460,9 +403,6 @@ void drm_lastclose(struct drm_device * dev)
> dev->driver->lastclose(dev);
> drm_dbg_core(dev, "driver lastclose completed\n");
>
> - if (drm_core_check_feature(dev, DRIVER_LEGACY))
> - drm_legacy_dev_reinit(dev);
> -
> drm_client_dev_restore(dev);
> }
>
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index a11f164b2384f..702a12bc93bd9 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -210,11 +210,6 @@ static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
> if (crtc->funcs->get_vblank_counter)
> return crtc->funcs->get_vblank_counter(crtc);
> }
> -#ifdef CONFIG_DRM_LEGACY
> - else if (dev->driver->get_vblank_counter) {
> - return dev->driver->get_vblank_counter(dev, pipe);
> - }
> -#endif
>
> return drm_vblank_no_hw_counter(dev, pipe);
> }
> @@ -433,11 +428,6 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
> if (crtc->funcs->disable_vblank)
> crtc->funcs->disable_vblank(crtc);
> }
> -#ifdef CONFIG_DRM_LEGACY
> - else {
> - dev->driver->disable_vblank(dev, pipe);
> - }
> -#endif
> }
>
> /*
> @@ -1151,11 +1141,6 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
> if (crtc->funcs->enable_vblank)
> return crtc->funcs->enable_vblank(crtc);
> }
> -#ifdef CONFIG_DRM_LEGACY
> - else if (dev->driver->enable_vblank) {
> - return dev->driver->enable_vblank(dev, pipe);
> - }
> -#endif
>
> return -EINVAL;
> }
> @@ -1698,10 +1683,6 @@ static void drm_wait_vblank_reply(struct drm_device *dev, unsigned int pipe,
>
> static bool drm_wait_vblank_supported(struct drm_device *dev)
> {
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> - if (unlikely(drm_core_check_feature(dev, DRIVER_LEGACY)))
> - return dev->irq_enabled;
> -#endif
> return drm_dev_has_vblank(dev);
> }
>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED
2023-11-22 12:09 ` [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED Thomas Zimmermann
@ 2023-11-27 21:05 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:05 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Modern DRM drivers acquire ioctl locks by themselves. Legacy ioctls
> for user-space mode setting used to acquire drm_global_mutex. After
> removing the ioctl entry points, also remove the locking code. The only
> legacy ioctl without global locking was VBLANK_WAIT, which has been
> removed as well. Hence remove the related DRM_UNLOCKED flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/drm_ioc32.c | 2 +-
> drivers/gpu/drm/drm_ioctl.c | 23 +++++++----------------
> include/drm/drm_ioctl.h | 11 -----------
> 3 files changed, 8 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
> index 910cadf14756e..129e2b91dbfe7 100644
> --- a/drivers/gpu/drm/drm_ioc32.c
> +++ b/drivers/gpu/drm/drm_ioc32.c
> @@ -273,7 +273,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
> req.request.type = req32.request.type;
> req.request.sequence = req32.request.sequence;
> req.request.signal = req32.request.signal;
> - err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED);
> + err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, 0);
>
> req32.reply.type = req.reply.type;
> req32.reply.sequence = req.reply.sequence;
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 9c6326b908e74..1cf1de342d6aa 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -583,7 +583,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
>
> DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
>
> - DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
> + DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, 0),
>
> DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
>
> @@ -716,7 +716,7 @@ long drm_ioctl_kernel(struct file *file, drm_ioctl_t *func, void *kdata,
> {
> struct drm_file *file_priv = file->private_data;
> struct drm_device *dev = file_priv->minor->dev;
> - int retcode;
> + int ret;
>
> /* Update drm_file owner if fd was passed along. */
> drm_file_update_pid(file_priv);
> @@ -724,20 +724,11 @@ long drm_ioctl_kernel(struct file *file, drm_ioctl_t *func, void *kdata,
> if (drm_dev_is_unplugged(dev))
> return -ENODEV;
>
> - retcode = drm_ioctl_permit(flags, file_priv);
> - if (unlikely(retcode))
> - return retcode;
> -
> - /* Enforce sane locking for modern driver ioctls. */
> - if (likely(!drm_core_check_feature(dev, DRIVER_LEGACY)) ||
> - (flags & DRM_UNLOCKED))
> - retcode = func(dev, kdata, file_priv);
> - else {
> - mutex_lock(&drm_global_mutex);
> - retcode = func(dev, kdata, file_priv);
> - mutex_unlock(&drm_global_mutex);
> - }
> - return retcode;
> + ret = drm_ioctl_permit(flags, file_priv);
> + if (unlikely(ret))
> + return ret;
> +
> + return func(dev, kdata, file_priv);
> }
> EXPORT_SYMBOL(drm_ioctl_kernel);
>
> diff --git a/include/drm/drm_ioctl.h b/include/drm/drm_ioctl.h
> index 6ed61c371f6ce..171760b6c4a14 100644
> --- a/include/drm/drm_ioctl.h
> +++ b/include/drm/drm_ioctl.h
> @@ -109,17 +109,6 @@ enum drm_ioctl_flags {
> * This is equivalent to callers with the SYSADMIN capability.
> */
> DRM_ROOT_ONLY = BIT(2),
> - /**
> - * @DRM_UNLOCKED:
> - *
> - * Whether &drm_ioctl_desc.func should be called with the DRM BKL held
> - * or not. Enforced as the default for all modern drivers, hence there
> - * should never be a need to set this flag.
> - *
> - * Do not use anywhere else than for the VBLANK_WAIT IOCTL, which is the
> - * only legacy IOCTL which needs this.
> - */
> - DRM_UNLOCKED = BIT(4),
> /**
> * @DRM_RENDER_ALLOW:
> *
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 12/14] drm: Remove source code for non-KMS drivers
2023-11-22 12:09 ` [PATCH 12/14] drm: Remove source code for non-KMS drivers Thomas Zimmermann
@ 2023-11-27 21:06 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:06 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Remove all remaining source code for non-KMS drivers. These drivers
> have been removed in v6.3 and won't comeback.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 13/14] char/agp: Remove frontend code
2023-11-22 12:09 ` [PATCH 13/14] char/agp: Remove frontend code Thomas Zimmermann
@ 2023-11-27 21:07 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:07 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> The AGP subsystem supports a user-space interface via /dev/agpgart. It
> is only enabled with DRM support for mode setting in user space. (i.e.,
> CONFIG_DRM_LEGACY). All of that DRM code has been removed and the option
> will go away. Hence remove the AGP frontend.
>
> Modern DRM drivers with kernel mode setting handle AGP support internally.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/char/agp/Makefile | 6 -
> drivers/char/agp/agp.h | 9 -
> drivers/char/agp/backend.c | 11 -
> drivers/char/agp/compat_ioctl.c | 291 ---------
> drivers/char/agp/compat_ioctl.h | 106 ---
> drivers/char/agp/frontend.c | 1068 -------------------------------
> 6 files changed, 1491 deletions(-)
> delete mode 100644 drivers/char/agp/compat_ioctl.c
> delete mode 100644 drivers/char/agp/compat_ioctl.h
> delete mode 100644 drivers/char/agp/frontend.c
>
> diff --git a/drivers/char/agp/Makefile b/drivers/char/agp/Makefile
> index 25834557e4865..43b09cf193bb7 100644
> --- a/drivers/char/agp/Makefile
> +++ b/drivers/char/agp/Makefile
> @@ -1,12 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0
> agpgart-y := backend.o generic.o isoch.o
>
> -ifeq ($(CONFIG_DRM_LEGACY),y)
> -agpgart-$(CONFIG_COMPAT) += compat_ioctl.o
> -agpgart-y += frontend.o
> -endif
> -
> -
> obj-$(CONFIG_AGP) += agpgart.o
> obj-$(CONFIG_AGP_ALI) += ali-agp.o
> obj-$(CONFIG_AGP_ATI) += ati-agp.o
> diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
> index 8771dcc9b8e2f..5c36ab85f80b7 100644
> --- a/drivers/char/agp/agp.h
> +++ b/drivers/char/agp/agp.h
> @@ -185,15 +185,6 @@ void agp_put_bridge(struct agp_bridge_data *bridge);
> int agp_add_bridge(struct agp_bridge_data *bridge);
> void agp_remove_bridge(struct agp_bridge_data *bridge);
>
> -/* Frontend routines. */
> -#if IS_ENABLED(CONFIG_DRM_LEGACY)
> -int agp_frontend_initialize(void);
> -void agp_frontend_cleanup(void);
> -#else
> -static inline int agp_frontend_initialize(void) { return 0; }
> -static inline void agp_frontend_cleanup(void) {}
> -#endif
> -
> /* Generic routines. */
> void agp_generic_enable(struct agp_bridge_data *bridge, u32 mode);
> int agp_generic_create_gatt_table(struct agp_bridge_data *bridge);
> diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
> index 0e19c600db531..1776afd3ee078 100644
> --- a/drivers/char/agp/backend.c
> +++ b/drivers/char/agp/backend.c
> @@ -293,13 +293,6 @@ int agp_add_bridge(struct agp_bridge_data *bridge)
> }
>
> if (list_empty(&agp_bridges)) {
> - error = agp_frontend_initialize();
> - if (error) {
> - dev_info(&bridge->dev->dev,
> - "agp_frontend_initialize() failed\n");
> - goto frontend_err;
> - }
> -
> dev_info(&bridge->dev->dev, "AGP aperture is %dM @ 0x%lx\n",
> bridge->driver->fetch_size(), bridge->gart_bus_addr);
>
> @@ -308,8 +301,6 @@ int agp_add_bridge(struct agp_bridge_data *bridge)
> list_add(&bridge->list, &agp_bridges);
> return 0;
>
> -frontend_err:
> - agp_backend_cleanup(bridge);
> err_out:
> module_put(bridge->driver->owner);
> err_put_bridge:
> @@ -323,8 +314,6 @@ void agp_remove_bridge(struct agp_bridge_data *bridge)
> {
> agp_backend_cleanup(bridge);
> list_del(&bridge->list);
> - if (list_empty(&agp_bridges))
> - agp_frontend_cleanup();
> module_put(bridge->driver->owner);
> }
> EXPORT_SYMBOL_GPL(agp_remove_bridge);
> diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
> deleted file mode 100644
> index 52ffe1706ce05..0000000000000
> --- a/drivers/char/agp/compat_ioctl.c
> +++ /dev/null
> @@ -1,291 +0,0 @@
> -/*
> - * AGPGART driver frontend compatibility ioctls
> - * Copyright (C) 2004 Silicon Graphics, Inc.
> - * Copyright (C) 2002-2003 Dave Jones
> - * Copyright (C) 1999 Jeff Hartmann
> - * Copyright (C) 1999 Precision Insight, Inc.
> - * Copyright (C) 1999 Xi Graphics, Inc.
> - *
> - * Permission is hereby granted, free of charge, to any person obtaining a
> - * copy of this software and associated documentation files (the "Software"),
> - * to deal in the Software without restriction, including without limitation
> - * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> - * and/or sell copies of the Software, and to permit persons to whom the
> - * Software is furnished to do so, subject to the following conditions:
> - *
> - * The above copyright notice and this permission notice shall be included
> - * in all copies or substantial portions of the Software.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> - * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
> - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
> - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> - *
> - */
> -
> -#include <linux/kernel.h>
> -#include <linux/pci.h>
> -#include <linux/fs.h>
> -#include <linux/agpgart.h>
> -#include <linux/slab.h>
> -#include <linux/uaccess.h>
> -#include "agp.h"
> -#include "compat_ioctl.h"
> -
> -static int compat_agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_info32 userinfo;
> - struct agp_kern_info kerninfo;
> -
> - agp_copy_info(agp_bridge, &kerninfo);
> -
> - userinfo.version.major = kerninfo.version.major;
> - userinfo.version.minor = kerninfo.version.minor;
> - userinfo.bridge_id = kerninfo.device->vendor |
> - (kerninfo.device->device << 16);
> - userinfo.agp_mode = kerninfo.mode;
> - userinfo.aper_base = (compat_long_t)kerninfo.aper_base;
> - userinfo.aper_size = kerninfo.aper_size;
> - userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
> - userinfo.pg_used = kerninfo.current_memory;
> -
> - if (copy_to_user(arg, &userinfo, sizeof(userinfo)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_region32 ureserve;
> - struct agp_region kreserve;
> - struct agp_client *client;
> - struct agp_file_private *client_priv;
> -
> - DBG("");
> - if (copy_from_user(&ureserve, arg, sizeof(ureserve)))
> - return -EFAULT;
> -
> - if ((unsigned) ureserve.seg_count >= ~0U/sizeof(struct agp_segment32))
> - return -EFAULT;
> -
> - kreserve.pid = ureserve.pid;
> - kreserve.seg_count = ureserve.seg_count;
> -
> - client = agp_find_client_by_pid(kreserve.pid);
> -
> - if (kreserve.seg_count == 0) {
> - /* remove a client */
> - client_priv = agp_find_private(kreserve.pid);
> -
> - if (client_priv != NULL) {
> - set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
> - set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
> - }
> - if (client == NULL) {
> - /* client is already removed */
> - return 0;
> - }
> - return agp_remove_client(kreserve.pid);
> - } else {
> - struct agp_segment32 *usegment;
> - struct agp_segment *ksegment;
> - int seg;
> -
> - if (ureserve.seg_count >= 16384)
> - return -EINVAL;
> -
> - usegment = kmalloc_array(ureserve.seg_count,
> - sizeof(*usegment),
> - GFP_KERNEL);
> - if (!usegment)
> - return -ENOMEM;
> -
> - ksegment = kmalloc_array(kreserve.seg_count,
> - sizeof(*ksegment),
> - GFP_KERNEL);
> - if (!ksegment) {
> - kfree(usegment);
> - return -ENOMEM;
> - }
> -
> - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
> - sizeof(*usegment) * ureserve.seg_count)) {
> - kfree(usegment);
> - kfree(ksegment);
> - return -EFAULT;
> - }
> -
> - for (seg = 0; seg < ureserve.seg_count; seg++) {
> - ksegment[seg].pg_start = usegment[seg].pg_start;
> - ksegment[seg].pg_count = usegment[seg].pg_count;
> - ksegment[seg].prot = usegment[seg].prot;
> - }
> -
> - kfree(usegment);
> - kreserve.seg_list = ksegment;
> -
> - if (client == NULL) {
> - /* Create the client and add the segment */
> - client = agp_create_client(kreserve.pid);
> -
> - if (client == NULL) {
> - kfree(ksegment);
> - return -ENOMEM;
> - }
> - client_priv = agp_find_private(kreserve.pid);
> -
> - if (client_priv != NULL) {
> - set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
> - set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
> - }
> - }
> - return agp_create_segment(client, &kreserve);
> - }
> - /* Will never really happen */
> - return -EINVAL;
> -}
> -
> -static int compat_agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_memory *memory;
> - struct agp_allocate32 alloc;
> -
> - DBG("");
> - if (copy_from_user(&alloc, arg, sizeof(alloc)))
> - return -EFAULT;
> -
> - memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
> -
> - if (memory == NULL)
> - return -ENOMEM;
> -
> - alloc.key = memory->key;
> - alloc.physical = memory->physical;
> -
> - if (copy_to_user(arg, &alloc, sizeof(alloc))) {
> - agp_free_memory_wrap(memory);
> - return -EFAULT;
> - }
> - return 0;
> -}
> -
> -static int compat_agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_bind32 bind_info;
> - struct agp_memory *memory;
> -
> - DBG("");
> - if (copy_from_user(&bind_info, arg, sizeof(bind_info)))
> - return -EFAULT;
> -
> - memory = agp_find_mem_by_key(bind_info.key);
> -
> - if (memory == NULL)
> - return -EINVAL;
> -
> - return agp_bind_memory(memory, bind_info.pg_start);
> -}
> -
> -static int compat_agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_memory *memory;
> - struct agp_unbind32 unbind;
> -
> - DBG("");
> - if (copy_from_user(&unbind, arg, sizeof(unbind)))
> - return -EFAULT;
> -
> - memory = agp_find_mem_by_key(unbind.key);
> -
> - if (memory == NULL)
> - return -EINVAL;
> -
> - return agp_unbind_memory(memory);
> -}
> -
> -long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> -{
> - struct agp_file_private *curr_priv = file->private_data;
> - int ret_val = -ENOTTY;
> -
> - mutex_lock(&(agp_fe.agp_mutex));
> -
> - if ((agp_fe.current_controller == NULL) &&
> - (cmd != AGPIOC_ACQUIRE32)) {
> - ret_val = -EINVAL;
> - goto ioctl_out;
> - }
> - if ((agp_fe.backend_acquired != true) &&
> - (cmd != AGPIOC_ACQUIRE32)) {
> - ret_val = -EBUSY;
> - goto ioctl_out;
> - }
> - if (cmd != AGPIOC_ACQUIRE32) {
> - if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
> - ret_val = -EPERM;
> - goto ioctl_out;
> - }
> - /* Use the original pid of the controller,
> - * in case it's threaded */
> -
> - if (agp_fe.current_controller->pid != curr_priv->my_pid) {
> - ret_val = -EBUSY;
> - goto ioctl_out;
> - }
> - }
> -
> - switch (cmd) {
> - case AGPIOC_INFO32:
> - ret_val = compat_agpioc_info_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_ACQUIRE32:
> - ret_val = agpioc_acquire_wrap(curr_priv);
> - break;
> -
> - case AGPIOC_RELEASE32:
> - ret_val = agpioc_release_wrap(curr_priv);
> - break;
> -
> - case AGPIOC_SETUP32:
> - ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_RESERVE32:
> - ret_val = compat_agpioc_reserve_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_PROTECT32:
> - ret_val = agpioc_protect_wrap(curr_priv);
> - break;
> -
> - case AGPIOC_ALLOCATE32:
> - ret_val = compat_agpioc_allocate_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_DEALLOCATE32:
> - ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
> - break;
> -
> - case AGPIOC_BIND32:
> - ret_val = compat_agpioc_bind_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_UNBIND32:
> - ret_val = compat_agpioc_unbind_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_CHIPSET_FLUSH32:
> - break;
> - }
> -
> -ioctl_out:
> - DBG("ioctl returns %d\n", ret_val);
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return ret_val;
> -}
> -
> diff --git a/drivers/char/agp/compat_ioctl.h b/drivers/char/agp/compat_ioctl.h
> deleted file mode 100644
> index f30e0fd979635..0000000000000
> --- a/drivers/char/agp/compat_ioctl.h
> +++ /dev/null
> @@ -1,106 +0,0 @@
> -/*
> - * Copyright (C) 1999 Jeff Hartmann
> - * Copyright (C) 1999 Precision Insight, Inc.
> - * Copyright (C) 1999 Xi Graphics, Inc.
> - *
> - * Permission is hereby granted, free of charge, to any person obtaining a
> - * copy of this software and associated documentation files (the "Software"),
> - * to deal in the Software without restriction, including without limitation
> - * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> - * and/or sell copies of the Software, and to permit persons to whom the
> - * Software is furnished to do so, subject to the following conditions:
> - *
> - * The above copyright notice and this permission notice shall be included
> - * in all copies or substantial portions of the Software.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> - * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
> - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
> - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> - *
> - */
> -
> -#ifndef _AGP_COMPAT_IOCTL_H
> -#define _AGP_COMPAT_IOCTL_H
> -
> -#include <linux/compat.h>
> -#include <linux/agpgart.h>
> -
> -#define AGPIOC_INFO32 _IOR (AGPIOC_BASE, 0, compat_uptr_t)
> -#define AGPIOC_ACQUIRE32 _IO (AGPIOC_BASE, 1)
> -#define AGPIOC_RELEASE32 _IO (AGPIOC_BASE, 2)
> -#define AGPIOC_SETUP32 _IOW (AGPIOC_BASE, 3, compat_uptr_t)
> -#define AGPIOC_RESERVE32 _IOW (AGPIOC_BASE, 4, compat_uptr_t)
> -#define AGPIOC_PROTECT32 _IOW (AGPIOC_BASE, 5, compat_uptr_t)
> -#define AGPIOC_ALLOCATE32 _IOWR(AGPIOC_BASE, 6, compat_uptr_t)
> -#define AGPIOC_DEALLOCATE32 _IOW (AGPIOC_BASE, 7, compat_int_t)
> -#define AGPIOC_BIND32 _IOW (AGPIOC_BASE, 8, compat_uptr_t)
> -#define AGPIOC_UNBIND32 _IOW (AGPIOC_BASE, 9, compat_uptr_t)
> -#define AGPIOC_CHIPSET_FLUSH32 _IO (AGPIOC_BASE, 10)
> -
> -struct agp_info32 {
> - struct agp_version version; /* version of the driver */
> - u32 bridge_id; /* bridge vendor/device */
> - u32 agp_mode; /* mode info of bridge */
> - compat_long_t aper_base; /* base of aperture */
> - compat_size_t aper_size; /* size of aperture */
> - compat_size_t pg_total; /* max pages (swap + system) */
> - compat_size_t pg_system; /* max pages (system) */
> - compat_size_t pg_used; /* current pages used */
> -};
> -
> -/*
> - * The "prot" down below needs still a "sleep" flag somehow ...
> - */
> -struct agp_segment32 {
> - compat_off_t pg_start; /* starting page to populate */
> - compat_size_t pg_count; /* number of pages */
> - compat_int_t prot; /* prot flags for mmap */
> -};
> -
> -struct agp_region32 {
> - compat_pid_t pid; /* pid of process */
> - compat_size_t seg_count; /* number of segments */
> - struct agp_segment32 *seg_list;
> -};
> -
> -struct agp_allocate32 {
> - compat_int_t key; /* tag of allocation */
> - compat_size_t pg_count; /* number of pages */
> - u32 type; /* 0 == normal, other devspec */
> - u32 physical; /* device specific (some devices
> - * need a phys address of the
> - * actual page behind the gatt
> - * table) */
> -};
> -
> -struct agp_bind32 {
> - compat_int_t key; /* tag of allocation */
> - compat_off_t pg_start; /* starting page to populate */
> -};
> -
> -struct agp_unbind32 {
> - compat_int_t key; /* tag of allocation */
> - u32 priority; /* priority for paging out */
> -};
> -
> -extern struct agp_front_data agp_fe;
> -
> -int agpioc_acquire_wrap(struct agp_file_private *priv);
> -int agpioc_release_wrap(struct agp_file_private *priv);
> -int agpioc_protect_wrap(struct agp_file_private *priv);
> -int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg);
> -int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg);
> -struct agp_file_private *agp_find_private(pid_t pid);
> -struct agp_client *agp_create_client(pid_t id);
> -int agp_remove_client(pid_t id);
> -int agp_create_segment(struct agp_client *client, struct agp_region *region);
> -void agp_free_memory_wrap(struct agp_memory *memory);
> -struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type);
> -struct agp_memory *agp_find_mem_by_key(int key);
> -struct agp_client *agp_find_client_by_pid(pid_t id);
> -
> -#endif /* _AGP_COMPAT_H */
> diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
> deleted file mode 100644
> index 321118a9cfa52..0000000000000
> --- a/drivers/char/agp/frontend.c
> +++ /dev/null
> @@ -1,1068 +0,0 @@
> -/*
> - * AGPGART driver frontend
> - * Copyright (C) 2004 Silicon Graphics, Inc.
> - * Copyright (C) 2002-2003 Dave Jones
> - * Copyright (C) 1999 Jeff Hartmann
> - * Copyright (C) 1999 Precision Insight, Inc.
> - * Copyright (C) 1999 Xi Graphics, Inc.
> - *
> - * Permission is hereby granted, free of charge, to any person obtaining a
> - * copy of this software and associated documentation files (the "Software"),
> - * to deal in the Software without restriction, including without limitation
> - * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> - * and/or sell copies of the Software, and to permit persons to whom the
> - * Software is furnished to do so, subject to the following conditions:
> - *
> - * The above copyright notice and this permission notice shall be included
> - * in all copies or substantial portions of the Software.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> - * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
> - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
> - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> - *
> - */
> -
> -#include <linux/types.h>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/mman.h>
> -#include <linux/pci.h>
> -#include <linux/miscdevice.h>
> -#include <linux/agp_backend.h>
> -#include <linux/agpgart.h>
> -#include <linux/slab.h>
> -#include <linux/mm.h>
> -#include <linux/fs.h>
> -#include <linux/sched.h>
> -#include <linux/uaccess.h>
> -
> -#include "agp.h"
> -#include "compat_ioctl.h"
> -
> -struct agp_front_data agp_fe;
> -
> -struct agp_memory *agp_find_mem_by_key(int key)
> -{
> - struct agp_memory *curr;
> -
> - if (agp_fe.current_controller == NULL)
> - return NULL;
> -
> - curr = agp_fe.current_controller->pool;
> -
> - while (curr != NULL) {
> - if (curr->key == key)
> - break;
> - curr = curr->next;
> - }
> -
> - DBG("key=%d -> mem=%p", key, curr);
> - return curr;
> -}
> -
> -static void agp_remove_from_pool(struct agp_memory *temp)
> -{
> - struct agp_memory *prev;
> - struct agp_memory *next;
> -
> - /* Check to see if this is even in the memory pool */
> -
> - DBG("mem=%p", temp);
> - if (agp_find_mem_by_key(temp->key) != NULL) {
> - next = temp->next;
> - prev = temp->prev;
> -
> - if (prev != NULL) {
> - prev->next = next;
> - if (next != NULL)
> - next->prev = prev;
> -
> - } else {
> - /* This is the first item on the list */
> - if (next != NULL)
> - next->prev = NULL;
> -
> - agp_fe.current_controller->pool = next;
> - }
> - }
> -}
> -
> -/*
> - * Routines for managing each client's segment list -
> - * These routines handle adding and removing segments
> - * to each auth'ed client.
> - */
> -
> -static struct
> -agp_segment_priv *agp_find_seg_in_client(const struct agp_client *client,
> - unsigned long offset,
> - int size, pgprot_t page_prot)
> -{
> - struct agp_segment_priv *seg;
> - int i;
> - off_t pg_start;
> - size_t pg_count;
> -
> - pg_start = offset / 4096;
> - pg_count = size / 4096;
> - seg = *(client->segments);
> -
> - for (i = 0; i < client->num_segments; i++) {
> - if ((seg[i].pg_start == pg_start) &&
> - (seg[i].pg_count == pg_count) &&
> - (pgprot_val(seg[i].prot) == pgprot_val(page_prot))) {
> - return seg + i;
> - }
> - }
> -
> - return NULL;
> -}
> -
> -static void agp_remove_seg_from_client(struct agp_client *client)
> -{
> - DBG("client=%p", client);
> -
> - if (client->segments != NULL) {
> - if (*(client->segments) != NULL) {
> - DBG("Freeing %p from client %p", *(client->segments), client);
> - kfree(*(client->segments));
> - }
> - DBG("Freeing %p from client %p", client->segments, client);
> - kfree(client->segments);
> - client->segments = NULL;
> - }
> -}
> -
> -static void agp_add_seg_to_client(struct agp_client *client,
> - struct agp_segment_priv ** seg, int num_segments)
> -{
> - struct agp_segment_priv **prev_seg;
> -
> - prev_seg = client->segments;
> -
> - if (prev_seg != NULL)
> - agp_remove_seg_from_client(client);
> -
> - DBG("Adding seg %p (%d segments) to client %p", seg, num_segments, client);
> - client->num_segments = num_segments;
> - client->segments = seg;
> -}
> -
> -static pgprot_t agp_convert_mmap_flags(int prot)
> -{
> - unsigned long prot_bits;
> -
> - prot_bits = calc_vm_prot_bits(prot, 0) | VM_SHARED;
> - return vm_get_page_prot(prot_bits);
> -}
> -
> -int agp_create_segment(struct agp_client *client, struct agp_region *region)
> -{
> - struct agp_segment_priv **ret_seg;
> - struct agp_segment_priv *seg;
> - struct agp_segment *user_seg;
> - size_t i;
> -
> - seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
> - if (seg == NULL) {
> - kfree(region->seg_list);
> - region->seg_list = NULL;
> - return -ENOMEM;
> - }
> - user_seg = region->seg_list;
> -
> - for (i = 0; i < region->seg_count; i++) {
> - seg[i].pg_start = user_seg[i].pg_start;
> - seg[i].pg_count = user_seg[i].pg_count;
> - seg[i].prot = agp_convert_mmap_flags(user_seg[i].prot);
> - }
> - kfree(region->seg_list);
> - region->seg_list = NULL;
> -
> - ret_seg = kmalloc(sizeof(void *), GFP_KERNEL);
> - if (ret_seg == NULL) {
> - kfree(seg);
> - return -ENOMEM;
> - }
> - *ret_seg = seg;
> - agp_add_seg_to_client(client, ret_seg, region->seg_count);
> - return 0;
> -}
> -
> -/* End - Routines for managing each client's segment list */
> -
> -/* This function must only be called when current_controller != NULL */
> -static void agp_insert_into_pool(struct agp_memory * temp)
> -{
> - struct agp_memory *prev;
> -
> - prev = agp_fe.current_controller->pool;
> -
> - if (prev != NULL) {
> - prev->prev = temp;
> - temp->next = prev;
> - }
> - agp_fe.current_controller->pool = temp;
> -}
> -
> -
> -/* File private list routines */
> -
> -struct agp_file_private *agp_find_private(pid_t pid)
> -{
> - struct agp_file_private *curr;
> -
> - curr = agp_fe.file_priv_list;
> -
> - while (curr != NULL) {
> - if (curr->my_pid == pid)
> - return curr;
> - curr = curr->next;
> - }
> -
> - return NULL;
> -}
> -
> -static void agp_insert_file_private(struct agp_file_private * priv)
> -{
> - struct agp_file_private *prev;
> -
> - prev = agp_fe.file_priv_list;
> -
> - if (prev != NULL)
> - prev->prev = priv;
> - priv->next = prev;
> - agp_fe.file_priv_list = priv;
> -}
> -
> -static void agp_remove_file_private(struct agp_file_private * priv)
> -{
> - struct agp_file_private *next;
> - struct agp_file_private *prev;
> -
> - next = priv->next;
> - prev = priv->prev;
> -
> - if (prev != NULL) {
> - prev->next = next;
> -
> - if (next != NULL)
> - next->prev = prev;
> -
> - } else {
> - if (next != NULL)
> - next->prev = NULL;
> -
> - agp_fe.file_priv_list = next;
> - }
> -}
> -
> -/* End - File flag list routines */
> -
> -/*
> - * Wrappers for agp_free_memory & agp_allocate_memory
> - * These make sure that internal lists are kept updated.
> - */
> -void agp_free_memory_wrap(struct agp_memory *memory)
> -{
> - agp_remove_from_pool(memory);
> - agp_free_memory(memory);
> -}
> -
> -struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
> -{
> - struct agp_memory *memory;
> -
> - memory = agp_allocate_memory(agp_bridge, pg_count, type);
> - if (memory == NULL)
> - return NULL;
> -
> - agp_insert_into_pool(memory);
> - return memory;
> -}
> -
> -/* Routines for managing the list of controllers -
> - * These routines manage the current controller, and the list of
> - * controllers
> - */
> -
> -static struct agp_controller *agp_find_controller_by_pid(pid_t id)
> -{
> - struct agp_controller *controller;
> -
> - controller = agp_fe.controllers;
> -
> - while (controller != NULL) {
> - if (controller->pid == id)
> - return controller;
> - controller = controller->next;
> - }
> -
> - return NULL;
> -}
> -
> -static struct agp_controller *agp_create_controller(pid_t id)
> -{
> - struct agp_controller *controller;
> -
> - controller = kzalloc(sizeof(struct agp_controller), GFP_KERNEL);
> - if (controller == NULL)
> - return NULL;
> -
> - controller->pid = id;
> - return controller;
> -}
> -
> -static int agp_insert_controller(struct agp_controller *controller)
> -{
> - struct agp_controller *prev_controller;
> -
> - prev_controller = agp_fe.controllers;
> - controller->next = prev_controller;
> -
> - if (prev_controller != NULL)
> - prev_controller->prev = controller;
> -
> - agp_fe.controllers = controller;
> -
> - return 0;
> -}
> -
> -static void agp_remove_all_clients(struct agp_controller *controller)
> -{
> - struct agp_client *client;
> - struct agp_client *temp;
> -
> - client = controller->clients;
> -
> - while (client) {
> - struct agp_file_private *priv;
> -
> - temp = client;
> - agp_remove_seg_from_client(temp);
> - priv = agp_find_private(temp->pid);
> -
> - if (priv != NULL) {
> - clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
> - clear_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
> - }
> - client = client->next;
> - kfree(temp);
> - }
> -}
> -
> -static void agp_remove_all_memory(struct agp_controller *controller)
> -{
> - struct agp_memory *memory;
> - struct agp_memory *temp;
> -
> - memory = controller->pool;
> -
> - while (memory) {
> - temp = memory;
> - memory = memory->next;
> - agp_free_memory_wrap(temp);
> - }
> -}
> -
> -static int agp_remove_controller(struct agp_controller *controller)
> -{
> - struct agp_controller *prev_controller;
> - struct agp_controller *next_controller;
> -
> - prev_controller = controller->prev;
> - next_controller = controller->next;
> -
> - if (prev_controller != NULL) {
> - prev_controller->next = next_controller;
> - if (next_controller != NULL)
> - next_controller->prev = prev_controller;
> -
> - } else {
> - if (next_controller != NULL)
> - next_controller->prev = NULL;
> -
> - agp_fe.controllers = next_controller;
> - }
> -
> - agp_remove_all_memory(controller);
> - agp_remove_all_clients(controller);
> -
> - if (agp_fe.current_controller == controller) {
> - agp_fe.current_controller = NULL;
> - agp_fe.backend_acquired = false;
> - agp_backend_release(agp_bridge);
> - }
> - kfree(controller);
> - return 0;
> -}
> -
> -static void agp_controller_make_current(struct agp_controller *controller)
> -{
> - struct agp_client *clients;
> -
> - clients = controller->clients;
> -
> - while (clients != NULL) {
> - struct agp_file_private *priv;
> -
> - priv = agp_find_private(clients->pid);
> -
> - if (priv != NULL) {
> - set_bit(AGP_FF_IS_VALID, &priv->access_flags);
> - set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
> - }
> - clients = clients->next;
> - }
> -
> - agp_fe.current_controller = controller;
> -}
> -
> -static void agp_controller_release_current(struct agp_controller *controller,
> - struct agp_file_private *controller_priv)
> -{
> - struct agp_client *clients;
> -
> - clear_bit(AGP_FF_IS_VALID, &controller_priv->access_flags);
> - clients = controller->clients;
> -
> - while (clients != NULL) {
> - struct agp_file_private *priv;
> -
> - priv = agp_find_private(clients->pid);
> -
> - if (priv != NULL)
> - clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
> -
> - clients = clients->next;
> - }
> -
> - agp_fe.current_controller = NULL;
> - agp_fe.used_by_controller = false;
> - agp_backend_release(agp_bridge);
> -}
> -
> -/*
> - * Routines for managing client lists -
> - * These routines are for managing the list of auth'ed clients.
> - */
> -
> -static struct agp_client
> -*agp_find_client_in_controller(struct agp_controller *controller, pid_t id)
> -{
> - struct agp_client *client;
> -
> - if (controller == NULL)
> - return NULL;
> -
> - client = controller->clients;
> -
> - while (client != NULL) {
> - if (client->pid == id)
> - return client;
> - client = client->next;
> - }
> -
> - return NULL;
> -}
> -
> -static struct agp_controller *agp_find_controller_for_client(pid_t id)
> -{
> - struct agp_controller *controller;
> -
> - controller = agp_fe.controllers;
> -
> - while (controller != NULL) {
> - if ((agp_find_client_in_controller(controller, id)) != NULL)
> - return controller;
> - controller = controller->next;
> - }
> -
> - return NULL;
> -}
> -
> -struct agp_client *agp_find_client_by_pid(pid_t id)
> -{
> - struct agp_client *temp;
> -
> - if (agp_fe.current_controller == NULL)
> - return NULL;
> -
> - temp = agp_find_client_in_controller(agp_fe.current_controller, id);
> - return temp;
> -}
> -
> -static void agp_insert_client(struct agp_client *client)
> -{
> - struct agp_client *prev_client;
> -
> - prev_client = agp_fe.current_controller->clients;
> - client->next = prev_client;
> -
> - if (prev_client != NULL)
> - prev_client->prev = client;
> -
> - agp_fe.current_controller->clients = client;
> - agp_fe.current_controller->num_clients++;
> -}
> -
> -struct agp_client *agp_create_client(pid_t id)
> -{
> - struct agp_client *new_client;
> -
> - new_client = kzalloc(sizeof(struct agp_client), GFP_KERNEL);
> - if (new_client == NULL)
> - return NULL;
> -
> - new_client->pid = id;
> - agp_insert_client(new_client);
> - return new_client;
> -}
> -
> -int agp_remove_client(pid_t id)
> -{
> - struct agp_client *client;
> - struct agp_client *prev_client;
> - struct agp_client *next_client;
> - struct agp_controller *controller;
> -
> - controller = agp_find_controller_for_client(id);
> - if (controller == NULL)
> - return -EINVAL;
> -
> - client = agp_find_client_in_controller(controller, id);
> - if (client == NULL)
> - return -EINVAL;
> -
> - prev_client = client->prev;
> - next_client = client->next;
> -
> - if (prev_client != NULL) {
> - prev_client->next = next_client;
> - if (next_client != NULL)
> - next_client->prev = prev_client;
> -
> - } else {
> - if (next_client != NULL)
> - next_client->prev = NULL;
> - controller->clients = next_client;
> - }
> -
> - controller->num_clients--;
> - agp_remove_seg_from_client(client);
> - kfree(client);
> - return 0;
> -}
> -
> -/* End - Routines for managing client lists */
> -
> -/* File Operations */
> -
> -static int agp_mmap(struct file *file, struct vm_area_struct *vma)
> -{
> - unsigned int size, current_size;
> - unsigned long offset;
> - struct agp_client *client;
> - struct agp_file_private *priv = file->private_data;
> - struct agp_kern_info kerninfo;
> -
> - mutex_lock(&(agp_fe.agp_mutex));
> -
> - if (agp_fe.backend_acquired != true)
> - goto out_eperm;
> -
> - if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
> - goto out_eperm;
> -
> - agp_copy_info(agp_bridge, &kerninfo);
> - size = vma->vm_end - vma->vm_start;
> - current_size = kerninfo.aper_size;
> - current_size = current_size * 0x100000;
> - offset = vma->vm_pgoff << PAGE_SHIFT;
> - DBG("%lx:%lx", offset, offset+size);
> -
> - if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) {
> - if ((size + offset) > current_size)
> - goto out_inval;
> -
> - client = agp_find_client_by_pid(current->pid);
> -
> - if (client == NULL)
> - goto out_eperm;
> -
> - if (!agp_find_seg_in_client(client, offset, size, vma->vm_page_prot))
> - goto out_inval;
> -
> - DBG("client vm_ops=%p", kerninfo.vm_ops);
> - if (kerninfo.vm_ops) {
> - vma->vm_ops = kerninfo.vm_ops;
> - } else if (io_remap_pfn_range(vma, vma->vm_start,
> - (kerninfo.aper_base + offset) >> PAGE_SHIFT,
> - size,
> - pgprot_writecombine(vma->vm_page_prot))) {
> - goto out_again;
> - }
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return 0;
> - }
> -
> - if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
> - if (size != current_size)
> - goto out_inval;
> -
> - DBG("controller vm_ops=%p", kerninfo.vm_ops);
> - if (kerninfo.vm_ops) {
> - vma->vm_ops = kerninfo.vm_ops;
> - } else if (io_remap_pfn_range(vma, vma->vm_start,
> - kerninfo.aper_base >> PAGE_SHIFT,
> - size,
> - pgprot_writecombine(vma->vm_page_prot))) {
> - goto out_again;
> - }
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return 0;
> - }
> -
> -out_eperm:
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return -EPERM;
> -
> -out_inval:
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return -EINVAL;
> -
> -out_again:
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return -EAGAIN;
> -}
> -
> -static int agp_release(struct inode *inode, struct file *file)
> -{
> - struct agp_file_private *priv = file->private_data;
> -
> - mutex_lock(&(agp_fe.agp_mutex));
> -
> - DBG("priv=%p", priv);
> -
> - if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
> - struct agp_controller *controller;
> -
> - controller = agp_find_controller_by_pid(priv->my_pid);
> -
> - if (controller != NULL) {
> - if (controller == agp_fe.current_controller)
> - agp_controller_release_current(controller, priv);
> - agp_remove_controller(controller);
> - controller = NULL;
> - }
> - }
> -
> - if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags))
> - agp_remove_client(priv->my_pid);
> -
> - agp_remove_file_private(priv);
> - kfree(priv);
> - file->private_data = NULL;
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return 0;
> -}
> -
> -static int agp_open(struct inode *inode, struct file *file)
> -{
> - int minor = iminor(inode);
> - struct agp_file_private *priv;
> - struct agp_client *client;
> -
> - if (minor != AGPGART_MINOR)
> - return -ENXIO;
> -
> - mutex_lock(&(agp_fe.agp_mutex));
> -
> - priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
> - if (priv == NULL) {
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return -ENOMEM;
> - }
> -
> - set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
> - priv->my_pid = current->pid;
> -
> - if (capable(CAP_SYS_RAWIO))
> - /* Root priv, can be controller */
> - set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags);
> -
> - client = agp_find_client_by_pid(current->pid);
> -
> - if (client != NULL) {
> - set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
> - set_bit(AGP_FF_IS_VALID, &priv->access_flags);
> - }
> - file->private_data = (void *) priv;
> - agp_insert_file_private(priv);
> - DBG("private=%p, client=%p", priv, client);
> -
> - mutex_unlock(&(agp_fe.agp_mutex));
> -
> - return 0;
> -}
> -
> -static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_info userinfo;
> - struct agp_kern_info kerninfo;
> -
> - agp_copy_info(agp_bridge, &kerninfo);
> -
> - memset(&userinfo, 0, sizeof(userinfo));
> - userinfo.version.major = kerninfo.version.major;
> - userinfo.version.minor = kerninfo.version.minor;
> - userinfo.bridge_id = kerninfo.device->vendor |
> - (kerninfo.device->device << 16);
> - userinfo.agp_mode = kerninfo.mode;
> - userinfo.aper_base = kerninfo.aper_base;
> - userinfo.aper_size = kerninfo.aper_size;
> - userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
> - userinfo.pg_used = kerninfo.current_memory;
> -
> - if (copy_to_user(arg, &userinfo, sizeof(struct agp_info)))
> - return -EFAULT;
> -
> - return 0;
> -}
> -
> -int agpioc_acquire_wrap(struct agp_file_private *priv)
> -{
> - struct agp_controller *controller;
> -
> - DBG("");
> -
> - if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags)))
> - return -EPERM;
> -
> - if (agp_fe.current_controller != NULL)
> - return -EBUSY;
> -
> - if (!agp_bridge)
> - return -ENODEV;
> -
> - if (atomic_read(&agp_bridge->agp_in_use))
> - return -EBUSY;
> -
> - atomic_inc(&agp_bridge->agp_in_use);
> -
> - agp_fe.backend_acquired = true;
> -
> - controller = agp_find_controller_by_pid(priv->my_pid);
> -
> - if (controller != NULL) {
> - agp_controller_make_current(controller);
> - } else {
> - controller = agp_create_controller(priv->my_pid);
> -
> - if (controller == NULL) {
> - agp_fe.backend_acquired = false;
> - agp_backend_release(agp_bridge);
> - return -ENOMEM;
> - }
> - agp_insert_controller(controller);
> - agp_controller_make_current(controller);
> - }
> -
> - set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags);
> - set_bit(AGP_FF_IS_VALID, &priv->access_flags);
> - return 0;
> -}
> -
> -int agpioc_release_wrap(struct agp_file_private *priv)
> -{
> - DBG("");
> - agp_controller_release_current(agp_fe.current_controller, priv);
> - return 0;
> -}
> -
> -int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_setup mode;
> -
> - DBG("");
> - if (copy_from_user(&mode, arg, sizeof(struct agp_setup)))
> - return -EFAULT;
> -
> - agp_enable(agp_bridge, mode.agp_mode);
> - return 0;
> -}
> -
> -static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_region reserve;
> - struct agp_client *client;
> - struct agp_file_private *client_priv;
> -
> - DBG("");
> - if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
> - return -EFAULT;
> -
> - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
> - return -EFAULT;
> -
> - client = agp_find_client_by_pid(reserve.pid);
> -
> - if (reserve.seg_count == 0) {
> - /* remove a client */
> - client_priv = agp_find_private(reserve.pid);
> -
> - if (client_priv != NULL) {
> - set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
> - set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
> - }
> - if (client == NULL) {
> - /* client is already removed */
> - return 0;
> - }
> - return agp_remove_client(reserve.pid);
> - } else {
> - struct agp_segment *segment;
> -
> - if (reserve.seg_count >= 16384)
> - return -EINVAL;
> -
> - segment = kmalloc((sizeof(struct agp_segment) * reserve.seg_count),
> - GFP_KERNEL);
> -
> - if (segment == NULL)
> - return -ENOMEM;
> -
> - if (copy_from_user(segment, (void __user *) reserve.seg_list,
> - sizeof(struct agp_segment) * reserve.seg_count)) {
> - kfree(segment);
> - return -EFAULT;
> - }
> - reserve.seg_list = segment;
> -
> - if (client == NULL) {
> - /* Create the client and add the segment */
> - client = agp_create_client(reserve.pid);
> -
> - if (client == NULL) {
> - kfree(segment);
> - return -ENOMEM;
> - }
> - client_priv = agp_find_private(reserve.pid);
> -
> - if (client_priv != NULL) {
> - set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
> - set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
> - }
> - }
> - return agp_create_segment(client, &reserve);
> - }
> - /* Will never really happen */
> - return -EINVAL;
> -}
> -
> -int agpioc_protect_wrap(struct agp_file_private *priv)
> -{
> - DBG("");
> - /* This function is not currently implemented */
> - return -EINVAL;
> -}
> -
> -static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_memory *memory;
> - struct agp_allocate alloc;
> -
> - DBG("");
> - if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate)))
> - return -EFAULT;
> -
> - if (alloc.type >= AGP_USER_TYPES)
> - return -EINVAL;
> -
> - memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
> -
> - if (memory == NULL)
> - return -ENOMEM;
> -
> - alloc.key = memory->key;
> - alloc.physical = memory->physical;
> -
> - if (copy_to_user(arg, &alloc, sizeof(struct agp_allocate))) {
> - agp_free_memory_wrap(memory);
> - return -EFAULT;
> - }
> - return 0;
> -}
> -
> -int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg)
> -{
> - struct agp_memory *memory;
> -
> - DBG("");
> - memory = agp_find_mem_by_key(arg);
> -
> - if (memory == NULL)
> - return -EINVAL;
> -
> - agp_free_memory_wrap(memory);
> - return 0;
> -}
> -
> -static int agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_bind bind_info;
> - struct agp_memory *memory;
> -
> - DBG("");
> - if (copy_from_user(&bind_info, arg, sizeof(struct agp_bind)))
> - return -EFAULT;
> -
> - memory = agp_find_mem_by_key(bind_info.key);
> -
> - if (memory == NULL)
> - return -EINVAL;
> -
> - return agp_bind_memory(memory, bind_info.pg_start);
> -}
> -
> -static int agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
> -{
> - struct agp_memory *memory;
> - struct agp_unbind unbind;
> -
> - DBG("");
> - if (copy_from_user(&unbind, arg, sizeof(struct agp_unbind)))
> - return -EFAULT;
> -
> - memory = agp_find_mem_by_key(unbind.key);
> -
> - if (memory == NULL)
> - return -EINVAL;
> -
> - return agp_unbind_memory(memory);
> -}
> -
> -static long agp_ioctl(struct file *file,
> - unsigned int cmd, unsigned long arg)
> -{
> - struct agp_file_private *curr_priv = file->private_data;
> - int ret_val = -ENOTTY;
> -
> - DBG("priv=%p, cmd=%x", curr_priv, cmd);
> - mutex_lock(&(agp_fe.agp_mutex));
> -
> - if ((agp_fe.current_controller == NULL) &&
> - (cmd != AGPIOC_ACQUIRE)) {
> - ret_val = -EINVAL;
> - goto ioctl_out;
> - }
> - if ((agp_fe.backend_acquired != true) &&
> - (cmd != AGPIOC_ACQUIRE)) {
> - ret_val = -EBUSY;
> - goto ioctl_out;
> - }
> - if (cmd != AGPIOC_ACQUIRE) {
> - if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
> - ret_val = -EPERM;
> - goto ioctl_out;
> - }
> - /* Use the original pid of the controller,
> - * in case it's threaded */
> -
> - if (agp_fe.current_controller->pid != curr_priv->my_pid) {
> - ret_val = -EBUSY;
> - goto ioctl_out;
> - }
> - }
> -
> - switch (cmd) {
> - case AGPIOC_INFO:
> - ret_val = agpioc_info_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_ACQUIRE:
> - ret_val = agpioc_acquire_wrap(curr_priv);
> - break;
> -
> - case AGPIOC_RELEASE:
> - ret_val = agpioc_release_wrap(curr_priv);
> - break;
> -
> - case AGPIOC_SETUP:
> - ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_RESERVE:
> - ret_val = agpioc_reserve_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_PROTECT:
> - ret_val = agpioc_protect_wrap(curr_priv);
> - break;
> -
> - case AGPIOC_ALLOCATE:
> - ret_val = agpioc_allocate_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_DEALLOCATE:
> - ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
> - break;
> -
> - case AGPIOC_BIND:
> - ret_val = agpioc_bind_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_UNBIND:
> - ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
> - break;
> -
> - case AGPIOC_CHIPSET_FLUSH:
> - break;
> - }
> -
> -ioctl_out:
> - DBG("ioctl returns %d\n", ret_val);
> - mutex_unlock(&(agp_fe.agp_mutex));
> - return ret_val;
> -}
> -
> -static const struct file_operations agp_fops =
> -{
> - .owner = THIS_MODULE,
> - .llseek = no_llseek,
> - .unlocked_ioctl = agp_ioctl,
> -#ifdef CONFIG_COMPAT
> - .compat_ioctl = compat_agp_ioctl,
> -#endif
> - .mmap = agp_mmap,
> - .open = agp_open,
> - .release = agp_release,
> -};
> -
> -static struct miscdevice agp_miscdev =
> -{
> - .minor = AGPGART_MINOR,
> - .name = "agpgart",
> - .fops = &agp_fops
> -};
> -
> -int agp_frontend_initialize(void)
> -{
> - memset(&agp_fe, 0, sizeof(struct agp_front_data));
> - mutex_init(&(agp_fe.agp_mutex));
> -
> - if (misc_register(&agp_miscdev)) {
> - printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR);
> - return -EIO;
> - }
> - return 0;
> -}
> -
> -void agp_frontend_cleanup(void)
> -{
> - misc_deregister(&agp_miscdev);
> -}
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY)
2023-11-22 12:09 ` [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY) Thomas Zimmermann
@ 2023-11-27 21:07 ` Alex Deucher
0 siblings, 0 replies; 39+ messages in thread
From: Alex Deucher @ 2023-11-27 21:07 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, cai.huoqing, mripard
On Wed, Nov 22, 2023 at 7:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Remove CONFIG_DRM_LEGACY from Kconfig. Nothing depends on the option.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/Kconfig | 21 ---------------------
> 1 file changed, 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index cdbc56e076498..5150c8699a8b5 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -407,27 +407,6 @@ config DRM_HYPERV
>
> If M is selected the module will be called hyperv_drm.
>
> -# Keep legacy drivers last
> -
> -menuconfig DRM_LEGACY
> - bool "Enable legacy drivers (DANGEROUS)"
> - depends on DRM && MMU
> - help
> - Enable legacy DRI1 drivers. Those drivers expose unsafe and dangerous
> - APIs to user-space, which can be used to circumvent access
> - restrictions and other security measures. For backwards compatibility
> - those drivers are still available, but their use is highly
> - inadvisable and might harm your system.
> -
> - You are recommended to use the safe modeset-only drivers instead, and
> - perform 3D emulation in user-space.
> -
> - Unless you have strong reasons to go rogue, say "N".
> -
> -if DRM_LEGACY
> -# leave here to list legacy drivers
> -endif # DRM_LEGACY
> -
> config DRM_EXPORT_FOR_TESTS
> bool
>
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs
2023-11-22 12:09 ` Thomas Zimmermann
@ 2023-11-28 7:19 ` Cai Huoqing
-1 siblings, 0 replies; 39+ messages in thread
From: Cai Huoqing @ 2023-11-28 7:19 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: airlied, daniel, maarten.lankhorst, mripard, dri-devel,
Daniel Vetter, Dave Airlie, stable
On 22 11月 23 13:09:30, Thomas Zimmermann wrote:
> DRM drivers for user-space modesetting have been removed. Do not
> select the respective options in the default configs.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
Reviewed-by: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.3+
> ---
> arch/powerpc/configs/pmac32_defconfig | 2 --
> arch/powerpc/configs/ppc6xx_defconfig | 7 -------
> 2 files changed, 9 deletions(-)
>
> diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
> index 57ded82c28409..e41e7affd2482 100644
> --- a/arch/powerpc/configs/pmac32_defconfig
> +++ b/arch/powerpc/configs/pmac32_defconfig
> @@ -188,8 +188,6 @@ CONFIG_AGP=m
> CONFIG_AGP_UNINORTH=m
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_R128=m
> CONFIG_FB=y
> CONFIG_FB_OF=y
> CONFIG_FB_CONTROL=y
> diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
> index f279703425d45..e680cd086f0e8 100644
> --- a/arch/powerpc/configs/ppc6xx_defconfig
> +++ b/arch/powerpc/configs/ppc6xx_defconfig
> @@ -678,13 +678,6 @@ CONFIG_AGP=y
> CONFIG_AGP_UNINORTH=y
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_TDFX=m
> -CONFIG_DRM_R128=m
> -CONFIG_DRM_MGA=m
> -CONFIG_DRM_SIS=m
> -CONFIG_DRM_VIA=m
> -CONFIG_DRM_SAVAGE=m
> CONFIG_FB=y
> CONFIG_FB_CIRRUS=m
> CONFIG_FB_OF=y
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs
@ 2023-11-28 7:19 ` Cai Huoqing
0 siblings, 0 replies; 39+ messages in thread
From: Cai Huoqing @ 2023-11-28 7:19 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: Daniel Vetter, dri-devel, mripard, Dave Airlie, stable
On 22 11月 23 13:09:30, Thomas Zimmermann wrote:
> DRM drivers for user-space modesetting have been removed. Do not
> select the respective options in the default configs.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: a276afc19eec ("drm: Remove some obsolete drm pciids(tdfx, mga, i810, savage, r128, sis, via)")
Reviewed-by: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Cai Huoqing <cai.huoqing@linux.dev>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.3+
> ---
> arch/powerpc/configs/pmac32_defconfig | 2 --
> arch/powerpc/configs/ppc6xx_defconfig | 7 -------
> 2 files changed, 9 deletions(-)
>
> diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
> index 57ded82c28409..e41e7affd2482 100644
> --- a/arch/powerpc/configs/pmac32_defconfig
> +++ b/arch/powerpc/configs/pmac32_defconfig
> @@ -188,8 +188,6 @@ CONFIG_AGP=m
> CONFIG_AGP_UNINORTH=m
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_R128=m
> CONFIG_FB=y
> CONFIG_FB_OF=y
> CONFIG_FB_CONTROL=y
> diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
> index f279703425d45..e680cd086f0e8 100644
> --- a/arch/powerpc/configs/ppc6xx_defconfig
> +++ b/arch/powerpc/configs/ppc6xx_defconfig
> @@ -678,13 +678,6 @@ CONFIG_AGP=y
> CONFIG_AGP_UNINORTH=y
> CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> -CONFIG_DRM_LEGACY=y
> -CONFIG_DRM_TDFX=m
> -CONFIG_DRM_R128=m
> -CONFIG_DRM_MGA=m
> -CONFIG_DRM_SIS=m
> -CONFIG_DRM_VIA=m
> -CONFIG_DRM_SAVAGE=m
> CONFIG_FB=y
> CONFIG_FB_CIRRUS=m
> CONFIG_FB_OF=y
> --
> 2.42.1
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 00/14] drm: Remove infrastructure for user-space mode setting
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (13 preceding siblings ...)
2023-11-22 12:09 ` [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY) Thomas Zimmermann
@ 2023-12-01 8:39 ` Thomas Zimmermann
2023-12-06 9:20 ` Thomas Zimmermann
15 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-12-01 8:39 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing; +Cc: dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 5603 bytes --]
Am 22.11.23 um 13:09 schrieb Thomas Zimmermann:
> The old drivers for user-space mode setting have been removed in Linux
> v6.3. No one has complained or requested their return. It is time to
> remove these drivers' infrastructure from the DRM core.
FTR: acked by airlied and sima via dri-devel
https://people.freedesktop.org/~cbrill/dri-log/?channel=dri-devel&highlight_names=&date=2023-11-30
>
> The recent Linux v6.6 has been designated as long-term release, [1] so
> any remaining users have a few more years to get a new graphics card. The
> legacy devices continue to be supported via simpledrm. Merging proper
> drivers with kernel mode setting is also an option.
>
> Patches 1 to 7 fix a few trivial issues that have been forgotten during
> the removal of the drivers.
>
> Patches 8 and 9 remove the leagcy ioctl interfaces. One op is different
> from the others, so it gets its own patch.
>
> Patches 10 to 12 remove the legacy source code from DRM. With that gone
> patch 13, the AGP code can be simplified as well. There used to be
> a device file for user-space mode setting, /dev/agpgart, that is now
> obsolete.
>
> Patch 14 removes the option from Kconfig.
>
> [1] https://kernel.org/category/releases.html
>
> Thomas Zimmermann (14):
> arch/powerpc: Remove legacy DRM drivers from default configs
> drm: Fix TODO list mentioning non-KMS drivers
> drm: Include <drm/drm_auth.h>
> drm/i915: Include <drm/drm_auth.h>
> accel: Include <drm/drm_auth.h>
> drm: Include <drm/drm_device.h>
> drm/radeon: Do not include <drm/drm_legacy.h>
> drm: Remove entry points for legacy ioctls
> drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl
> drm: Remove support for legacy drivers
> drm: Remove locking for legacy ioctls and DRM_UNLOCKED
> drm: Remove source code for non-KMS drivers
> char/agp: Remove frontend code
> drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY)
>
> Documentation/gpu/todo.rst | 7 +-
> arch/powerpc/configs/pmac32_defconfig | 2 -
> arch/powerpc/configs/ppc6xx_defconfig | 7 -
> drivers/accel/drm_accel.c | 1 +
> drivers/char/agp/Makefile | 6 -
> drivers/char/agp/agp.h | 9 -
> drivers/char/agp/backend.c | 11 -
> drivers/char/agp/compat_ioctl.c | 291 ---
> drivers/char/agp/compat_ioctl.h | 106 --
> drivers/char/agp/frontend.c | 1068 -----------
> drivers/gpu/drm/Kconfig | 21 -
> drivers/gpu/drm/Makefile | 12 -
> drivers/gpu/drm/drm_agpsupport.c | 451 -----
> drivers/gpu/drm/drm_auth.c | 8 +-
> drivers/gpu/drm/drm_bufs.c | 1627 -----------------
> drivers/gpu/drm/drm_context.c | 513 ------
> drivers/gpu/drm/drm_dma.c | 178 --
> drivers/gpu/drm/drm_drv.c | 17 -
> drivers/gpu/drm/drm_file.c | 64 +-
> drivers/gpu/drm/drm_hashtab.c | 203 --
> drivers/gpu/drm/drm_internal.h | 7 -
> drivers/gpu/drm/drm_ioc32.c | 613 +------
> drivers/gpu/drm/drm_ioctl.c | 82 +-
> drivers/gpu/drm/drm_irq.c | 204 ---
> drivers/gpu/drm/drm_legacy.h | 290 ---
> drivers/gpu/drm/drm_legacy_misc.c | 105 --
> drivers/gpu/drm/drm_lock.c | 373 ----
> drivers/gpu/drm/drm_memory.c | 138 --
> drivers/gpu/drm/drm_pci.c | 204 +--
> drivers/gpu/drm/drm_scatter.c | 220 ---
> drivers/gpu/drm/drm_vblank.c | 101 -
> drivers/gpu/drm/drm_vm.c | 665 -------
> .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
> drivers/gpu/drm/radeon/radeon_drv.h | 1 -
> include/drm/drm_auth.h | 22 -
> include/drm/drm_device.h | 71 +-
> include/drm/drm_drv.h | 19 -
> include/drm/drm_file.h | 5 -
> include/drm/drm_ioctl.h | 11 -
> include/drm/drm_legacy.h | 331 ----
> 40 files changed, 20 insertions(+), 8045 deletions(-)
> delete mode 100644 drivers/char/agp/compat_ioctl.c
> delete mode 100644 drivers/char/agp/compat_ioctl.h
> delete mode 100644 drivers/char/agp/frontend.c
> delete mode 100644 drivers/gpu/drm/drm_agpsupport.c
> delete mode 100644 drivers/gpu/drm/drm_bufs.c
> delete mode 100644 drivers/gpu/drm/drm_context.c
> delete mode 100644 drivers/gpu/drm/drm_dma.c
> delete mode 100644 drivers/gpu/drm/drm_hashtab.c
> delete mode 100644 drivers/gpu/drm/drm_irq.c
> delete mode 100644 drivers/gpu/drm/drm_legacy.h
> delete mode 100644 drivers/gpu/drm/drm_legacy_misc.c
> delete mode 100644 drivers/gpu/drm/drm_lock.c
> delete mode 100644 drivers/gpu/drm/drm_memory.c
> delete mode 100644 drivers/gpu/drm/drm_scatter.c
> delete mode 100644 drivers/gpu/drm/drm_vm.c
> delete mode 100644 include/drm/drm_legacy.h
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 00/14] drm: Remove infrastructure for user-space mode setting
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
` (14 preceding siblings ...)
2023-12-01 8:39 ` [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
@ 2023-12-06 9:20 ` Thomas Zimmermann
15 siblings, 0 replies; 39+ messages in thread
From: Thomas Zimmermann @ 2023-12-06 9:20 UTC (permalink / raw)
To: airlied, daniel, maarten.lankhorst, mripard, cai.huoqing; +Cc: dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 5619 bytes --]
Merged into drm-misc-next, except for patch 1. It's fairly independent
from the other patches and I'll resend it directly to the the PPC list.
Best regards
Thomas
Am 22.11.23 um 13:09 schrieb Thomas Zimmermann:
> The old drivers for user-space mode setting have been removed in Linux
> v6.3. No one has complained or requested their return. It is time to
> remove these drivers' infrastructure from the DRM core.
>
> The recent Linux v6.6 has been designated as long-term release, [1] so
> any remaining users have a few more years to get a new graphics card. The
> legacy devices continue to be supported via simpledrm. Merging proper
> drivers with kernel mode setting is also an option.
>
> Patches 1 to 7 fix a few trivial issues that have been forgotten during
> the removal of the drivers.
>
> Patches 8 and 9 remove the leagcy ioctl interfaces. One op is different
> from the others, so it gets its own patch.
>
> Patches 10 to 12 remove the legacy source code from DRM. With that gone
> patch 13, the AGP code can be simplified as well. There used to be
> a device file for user-space mode setting, /dev/agpgart, that is now
> obsolete.
>
> Patch 14 removes the option from Kconfig.
>
> [1] https://kernel.org/category/releases.html
>
> Thomas Zimmermann (14):
> arch/powerpc: Remove legacy DRM drivers from default configs
> drm: Fix TODO list mentioning non-KMS drivers
> drm: Include <drm/drm_auth.h>
> drm/i915: Include <drm/drm_auth.h>
> accel: Include <drm/drm_auth.h>
> drm: Include <drm/drm_device.h>
> drm/radeon: Do not include <drm/drm_legacy.h>
> drm: Remove entry points for legacy ioctls
> drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl
> drm: Remove support for legacy drivers
> drm: Remove locking for legacy ioctls and DRM_UNLOCKED
> drm: Remove source code for non-KMS drivers
> char/agp: Remove frontend code
> drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY)
>
> Documentation/gpu/todo.rst | 7 +-
> arch/powerpc/configs/pmac32_defconfig | 2 -
> arch/powerpc/configs/ppc6xx_defconfig | 7 -
> drivers/accel/drm_accel.c | 1 +
> drivers/char/agp/Makefile | 6 -
> drivers/char/agp/agp.h | 9 -
> drivers/char/agp/backend.c | 11 -
> drivers/char/agp/compat_ioctl.c | 291 ---
> drivers/char/agp/compat_ioctl.h | 106 --
> drivers/char/agp/frontend.c | 1068 -----------
> drivers/gpu/drm/Kconfig | 21 -
> drivers/gpu/drm/Makefile | 12 -
> drivers/gpu/drm/drm_agpsupport.c | 451 -----
> drivers/gpu/drm/drm_auth.c | 8 +-
> drivers/gpu/drm/drm_bufs.c | 1627 -----------------
> drivers/gpu/drm/drm_context.c | 513 ------
> drivers/gpu/drm/drm_dma.c | 178 --
> drivers/gpu/drm/drm_drv.c | 17 -
> drivers/gpu/drm/drm_file.c | 64 +-
> drivers/gpu/drm/drm_hashtab.c | 203 --
> drivers/gpu/drm/drm_internal.h | 7 -
> drivers/gpu/drm/drm_ioc32.c | 613 +------
> drivers/gpu/drm/drm_ioctl.c | 82 +-
> drivers/gpu/drm/drm_irq.c | 204 ---
> drivers/gpu/drm/drm_legacy.h | 290 ---
> drivers/gpu/drm/drm_legacy_misc.c | 105 --
> drivers/gpu/drm/drm_lock.c | 373 ----
> drivers/gpu/drm/drm_memory.c | 138 --
> drivers/gpu/drm/drm_pci.c | 204 +--
> drivers/gpu/drm/drm_scatter.c | 220 ---
> drivers/gpu/drm/drm_vblank.c | 101 -
> drivers/gpu/drm/drm_vm.c | 665 -------
> .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 +
> drivers/gpu/drm/radeon/radeon_drv.h | 1 -
> include/drm/drm_auth.h | 22 -
> include/drm/drm_device.h | 71 +-
> include/drm/drm_drv.h | 19 -
> include/drm/drm_file.h | 5 -
> include/drm/drm_ioctl.h | 11 -
> include/drm/drm_legacy.h | 331 ----
> 40 files changed, 20 insertions(+), 8045 deletions(-)
> delete mode 100644 drivers/char/agp/compat_ioctl.c
> delete mode 100644 drivers/char/agp/compat_ioctl.h
> delete mode 100644 drivers/char/agp/frontend.c
> delete mode 100644 drivers/gpu/drm/drm_agpsupport.c
> delete mode 100644 drivers/gpu/drm/drm_bufs.c
> delete mode 100644 drivers/gpu/drm/drm_context.c
> delete mode 100644 drivers/gpu/drm/drm_dma.c
> delete mode 100644 drivers/gpu/drm/drm_hashtab.c
> delete mode 100644 drivers/gpu/drm/drm_irq.c
> delete mode 100644 drivers/gpu/drm/drm_legacy.h
> delete mode 100644 drivers/gpu/drm/drm_legacy_misc.c
> delete mode 100644 drivers/gpu/drm/drm_lock.c
> delete mode 100644 drivers/gpu/drm/drm_memory.c
> delete mode 100644 drivers/gpu/drm/drm_scatter.c
> delete mode 100644 drivers/gpu/drm/drm_vm.c
> delete mode 100644 include/drm/drm_legacy.h
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2023-12-06 9:20 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
2023-11-22 12:09 ` [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-27 21:03 ` Alex Deucher
2023-11-28 7:19 ` Cai Huoqing
2023-11-28 7:19 ` Cai Huoqing
2023-11-22 12:09 ` [PATCH 02/14] drm: Fix TODO list mentioning non-KMS drivers Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
2023-11-27 21:02 ` Alex Deucher
2023-11-27 21:02 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 03/14] drm: Include <drm/drm_auth.h> Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-22 12:09 ` [Intel-gfx] [PATCH 04/14] drm/i915: " Thomas Zimmermann
2023-11-22 12:09 ` Thomas Zimmermann
2023-11-22 18:14 ` [Intel-gfx] " Jani Nikula
2023-11-22 18:14 ` Jani Nikula
2023-11-22 12:09 ` [PATCH 05/14] accel: " Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 06/14] drm: Include <drm/drm_device.h> Thomas Zimmermann
2023-11-22 12:09 ` [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h> Thomas Zimmermann
2023-11-27 21:00 ` Alex Deucher
2023-11-27 21:00 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 08/14] drm: Remove entry points for legacy ioctls Thomas Zimmermann
2023-11-27 21:04 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 10/14] drm: Remove support for legacy drivers Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 12/14] drm: Remove source code for non-KMS drivers Thomas Zimmermann
2023-11-27 21:06 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 13/14] char/agp: Remove frontend code Thomas Zimmermann
2023-11-27 21:07 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY) Thomas Zimmermann
2023-11-27 21:07 ` Alex Deucher
2023-12-01 8:39 ` [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
2023-12-06 9:20 ` Thomas Zimmermann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.