Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: Allow querying of the SVGA PCI id from the userspace

Mesa3D loaders require knowledge of the devices PCI id. SVGAv2 and v3
have different PCI id's, but the same driver is used to handle them both.
To allow Mesa3D svga driver to be loaded automatically for both SVGAv2
and SVGAv3 make the kernel return the PCI id of the currently running
device.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Reviewed-by: Maaz Mombasawala <mombasawalam@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220302152426.885214-6-zack@kde.org

+23 -13
+15 -12
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2022 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 27 27 28 28 #include "vmwgfx_drv.h" 29 29 #include "vmwgfx_devcaps.h" 30 - #include <drm/vmwgfx_drm.h> 31 30 #include "vmwgfx_kms.h" 31 + 32 + #include <drm/vmwgfx_drm.h> 33 + #include <linux/pci.h> 32 34 33 35 int vmw_getparam_ioctl(struct drm_device *dev, void *data, 34 36 struct drm_file *file_priv) ··· 64 62 break; 65 63 case DRM_VMW_PARAM_FIFO_HW_VERSION: 66 64 { 67 - if ((dev_priv->capabilities & SVGA_CAP_GBOBJECTS)) { 65 + if ((dev_priv->capabilities & SVGA_CAP_GBOBJECTS)) 68 66 param->value = SVGA3D_HWVERSION_WS8_B1; 69 - break; 70 - } 71 - 72 - param->value = 73 - vmw_fifo_mem_read(dev_priv, 74 - ((vmw_fifo_caps(dev_priv) & 75 - SVGA_FIFO_CAP_3D_HWVERSION_REVISED) ? 76 - SVGA_FIFO_3D_HWVERSION_REVISED : 77 - SVGA_FIFO_3D_HWVERSION)); 67 + else 68 + param->value = vmw_fifo_mem_read( 69 + dev_priv, 70 + ((vmw_fifo_caps(dev_priv) & 71 + SVGA_FIFO_CAP_3D_HWVERSION_REVISED) ? 72 + SVGA_FIFO_3D_HWVERSION_REVISED : 73 + SVGA_FIFO_3D_HWVERSION)); 78 74 break; 79 75 } 80 76 case DRM_VMW_PARAM_MAX_SURF_MEMORY: ··· 107 107 break; 108 108 case DRM_VMW_PARAM_GL43: 109 109 param->value = has_gl43_context(dev_priv); 110 + break; 111 + case DRM_VMW_PARAM_DEVICE_ID: 112 + param->value = to_pci_dev(dev_priv->drm.dev)->device; 110 113 break; 111 114 default: 112 115 return -EINVAL;
+8 -1
include/uapi/drm/vmwgfx_drm.h
··· 1 1 /************************************************************************** 2 2 * 3 - * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA 3 + * Copyright © 2009-2022 VMware, Inc., Palo Alto, CA., USA 4 4 * All Rights Reserved. 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a ··· 92 92 * 93 93 * DRM_VMW_PARAM_SM5 94 94 * SM5 support is enabled. 95 + * 96 + * DRM_VMW_PARAM_GL43 97 + * SM5.1+GL4.3 support is enabled. 98 + * 99 + * DRM_VMW_PARAM_DEVICE_ID 100 + * PCI ID of the underlying SVGA device. 95 101 */ 96 102 97 103 #define DRM_VMW_PARAM_NUM_STREAMS 0 ··· 117 111 #define DRM_VMW_PARAM_SM4_1 14 118 112 #define DRM_VMW_PARAM_SM5 15 119 113 #define DRM_VMW_PARAM_GL43 16 114 + #define DRM_VMW_PARAM_DEVICE_ID 17 120 115 121 116 /** 122 117 * enum drm_vmw_handle_type - handle type for ref ioctls