From nobody Tue Nov 26 05:24:20 2024 Received: from erminea.space (erminea.space [51.250.125.203]) by smtp.subspace.kernel.org (Postfix) with SMTP id 1C9D01E4929 for ; Mon, 21 Oct 2024 11:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.250.125.203 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729511557; cv=none; b=O2Ig1iPZsS7vQNZOcVhAmHYtRViPPiO61rRt7hI70jYxWl8gBKhUbdk+ukEtqM4uC0s04B2VsjYhVP3o3r91eHCTzeSZiAY9LpCMlC8GtH6uKebFbp8bJ9i5pNhMKi/qyt9EZA7XNLshTeidpfgrAGmhpx90MSUm+798lVc9mTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729511557; c=relaxed/simple; bh=fBOgAUdNDCZWG3KGA0hLFJBosJCirNqqo8lEj6awgt8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=X6OrHs4DKapaE75TT6AWx9uK4arn9g8sNLb3PyJiKtu0F4e6yANaPcZ2B9vFiWJ10/bkDrvPop2V3NNFH3T/E/v41fY8NJfIiAkLXVWfREj4xD8p3zTZf+KkobejY0u+kG3M239dR58mIMBDYurYQ/kkmEdGJKPMLBT0B5lTVNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=erminea.space; spf=pass smtp.mailfrom=erminea.space; arc=none smtp.client-ip=51.250.125.203 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=erminea.space Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=erminea.space Received: (qmail 20491 invoked from network); 21 Oct 2024 11:52:27 -0000 Received: from localhost. (HELO erminea.space) (127.0.0.1) by 0.0.0.0 with SMTP; 21 Oct 2024 11:52:27 -0000 Received: from localhost.localdomain ([37.204.49.201]) by erminea.space with ESMTPSA id h6SSHXtAFmcHUAAAH+dm7w (envelope-from ); Mon, 21 Oct 2024 14:52:27 +0300 From: Peter Shkenev To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/virtio: use generic dumb_map_offset implementation Date: Mon, 21 Oct 2024 14:52:05 +0300 Message-ID: <20241021115210.5439-1-mustela@erminea.space> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, virtio uses its own dumb_map_offset implementation, virtio_gpu_mode_dumb_mmap. It works similarly to generic implementation, drm_gem_dumb_map_offset, and using the generic implementation is preferable (and making drivers to do so is a task stated on the DRM subsystem's TODO list). Thus, make driver use the generic implementation. This includes VIRTGPU_MAP ioctl so it cannot be used to circumvent rules imposed by drm_gem_dumb_map_offset (imported objects cannot be mapped). Signed-off-by: Peter Shkenev --- Changes in v2: - Remove excessive include of drm_gem.h from virtgpu_ioctl.h - Remove obsoleted virtio_gpu_mode_dumb_mmap prototype from virtgpu_drv.h drivers/gpu/drm/virtio/virtgpu_drv.c | 1 - drivers/gpu/drm/virtio/virtgpu_drv.h | 3 --- drivers/gpu/drm/virtio/virtgpu_gem.c | 15 --------------- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 2 +- 4 files changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/= virtgpu_drv.c index ffca6e2e1c9a..909808398d66 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -184,7 +184,6 @@ static const struct drm_driver driver =3D { .postclose =3D virtio_gpu_driver_postclose, =20 .dumb_create =3D virtio_gpu_mode_dumb_create, - .dumb_map_offset =3D virtio_gpu_mode_dumb_mmap, =20 DRM_FBDEV_SHMEM_DRIVER_OPS, =20 diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/= virtgpu_drv.h index 64c236169db8..76f6f29f819a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -301,9 +301,6 @@ void virtio_gpu_gem_object_close(struct drm_gem_object = *obj, int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev, struct drm_mode_create_dumb *args); -int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv, - struct drm_device *dev, - uint32_t handle, uint64_t *offset_p); =20 struct virtio_gpu_object_array *virtio_gpu_array_alloc(u32 nents); struct virtio_gpu_object_array* diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/= virtgpu_gem.c index 7db48d17ee3a..aefbb49481f1 100644 --- a/drivers/gpu/drm/virtio/virtgpu_gem.c +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c @@ -99,21 +99,6 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_pr= iv, return ret; } =20 -int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv, - struct drm_device *dev, - uint32_t handle, uint64_t *offset_p) -{ - struct drm_gem_object *gobj; - - BUG_ON(!offset_p); - gobj =3D drm_gem_object_lookup(file_priv, handle); - if (gobj =3D=3D NULL) - return -ENOENT; - *offset_p =3D drm_vma_node_offset_addr(&gobj->vma_node); - drm_gem_object_put(gobj); - return 0; -} - int virtio_gpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file) { diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virti= o/virtgpu_ioctl.c index e4f76f315550..112142f4b618 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -80,7 +80,7 @@ static int virtio_gpu_map_ioctl(struct drm_device *dev, v= oid *data, struct virtio_gpu_device *vgdev =3D dev->dev_private; struct drm_virtgpu_map *virtio_gpu_map =3D data; =20 - return virtio_gpu_mode_dumb_mmap(file, vgdev->ddev, + return drm_gem_dumb_map_offset(file, vgdev->ddev, virtio_gpu_map->handle, &virtio_gpu_map->offset); } --=20 2.47.0