From 3d3140b5b0d0140dce34bffa6ebe84ad0687c477 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 6 Aug 2026 16:16:30 +0200 Subject: [PATCH] drm/amdgpu: get rid of amdgpu_drm_ioctl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the entire amdgpu_drm_ioctl handler system in favor of drm_ioctl, as amdgpu_drm_ioctl held a runtime_pm reference for every ioctl that passed through it, even if hardware access was not required. The runtime_pm references should now be handled by each individual IOCTL that requires the GPU to be awake. Hopefully all the IOCTLs that require hardware access were covered. v2 (Shahyan): Added commit description Signed-off-by: Pierre-Eric Pelloux-Prayer Signed-off-by: Shahyan Soltani Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/Makefile | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 23 +----------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h | 6 --- drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c | 45 ----------------------- 4 files changed, 2 insertions(+), 73 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 63a2f5fc99fc..55b5d11f1938 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -326,7 +326,6 @@ include $(FULL_AMD_PATH)/acp/Makefile amdgpu-y += $(AMD_ACP_FILES) endif -amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o amdgpu-$(CONFIG_HMM_MIRROR) += amdgpu_hmm.o diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index d364a9bc04c0..ab6f9131ac11 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -3056,25 +3056,6 @@ static int amdgpu_drm_release(struct inode *inode, struct file *filp) return drm_release(inode, filp); } -long amdgpu_drm_ioctl(struct file *filp, - unsigned int cmd, unsigned long arg) -{ - struct drm_file *file_priv = filp->private_data; - struct drm_device *dev; - long ret; - - dev = file_priv->minor->dev; - ret = pm_runtime_get_sync(dev->dev); - if (ret < 0) - goto out; - - ret = drm_ioctl(filp, cmd, arg); - -out: - pm_runtime_put_autosuspend(dev->dev); - return ret; -} - static const struct dev_pm_ops amdgpu_pm_ops = { .prepare = pm_sleep_ptr(amdgpu_pmops_prepare), .complete = pm_sleep_ptr(amdgpu_pmops_complete), @@ -3107,12 +3088,12 @@ static const struct file_operations amdgpu_driver_kms_fops = { .open = drm_open, .flush = amdgpu_flush, .release = amdgpu_drm_release, - .unlocked_ioctl = amdgpu_drm_ioctl, + .unlocked_ioctl = drm_ioctl, .mmap = drm_gem_mmap, .poll = drm_poll, .read = drm_read, #ifdef CONFIG_COMPAT - .compat_ioctl = amdgpu_kms_compat_ioctl, + .compat_ioctl = drm_compat_ioctl, #endif #ifdef CONFIG_PROC_FS .show_fdinfo = drm_show_fdinfo, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h index 2d86cc6f7f4d..6b06c0956e48 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h @@ -43,10 +43,4 @@ extern const struct drm_driver amdgpu_partition_driver; -long amdgpu_drm_ioctl(struct file *filp, - unsigned int cmd, unsigned long arg); - -long amdgpu_kms_compat_ioctl(struct file *filp, - unsigned int cmd, unsigned long arg); - #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c deleted file mode 100644 index a1cbd7c3deb2..000000000000 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ioc32.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * \file amdgpu_ioc32.c - * - * 32-bit ioctl compatibility routines for the AMDGPU DRM. - * - * \author Paul Mackerras - * - * Copyright (C) Paul Mackerras 2005 - * 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 - * THE AUTHOR 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 - -#include -#include - -#include "amdgpu_drv.h" - -long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - unsigned int nr = DRM_IOCTL_NR(cmd); - - if (nr < DRM_COMMAND_BASE) - return drm_compat_ioctl(filp, cmd, arg); - - return amdgpu_drm_ioctl(filp, cmd, arg); -}