vfio/igd: Use version mapping for MTL/ARL quirk selection
PATCH 1/1 vfio/igd: Use version mapping for MTL/ARL quirk selection
Meteor Lake and Arrow Lake use graphics IP version 12.70, but igd_gen() only returns the major version (generation). Encode the existing device ID mapping as (version * 100 + release) so that MTL/ARL can be selected in the BAR0 pcode stolen access quirk instead of a separate device ID check.
--- hw/vfio/igd.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
hw/vfio/igd.c +17 -13
@@ -58,8 +58,9 @@* not be taken as an indication that all the devices are supported, or even * supportable, some of them don't even support VT-d. * See linux:include/drm/i915_pciids.h for IDs. +* Returns (version * 100 + release). */ -static int igd_gen (VFIOPCIDevice *vdev) +static int igd_graphics_ver (VFIOPCIDevice *vdev) {/* * Device IDs for Broxton/Apollo Lake are 0x0a84, 0x1a84, 0x1a85, 0x5a84
@@ -67,38 +68,39 @@ static int igd_gen(VFIOPCIDevice *vdev)* Prefix 0x0a is taken by Haswell, this rule should be matched first. */ if ((vdev->device_id &0xffe ) ==0xa84 ) { -return 9 ; +return 900 ; }switch (vdev->device_id &0xff00 ) {case 0x0100 :/* SandyBridge, IvyBridge */ -return 6 ; +return 600 ;case 0x0400 :/* Haswell */ case 0x0a00 :/* Haswell */ case 0x0c00 :/* Haswell */ case 0x0d00 :/* Haswell */ case 0x0f00 :/* Valleyview/Bay Trail */ -return 7 ; +return 700 ;case 0x1600 :/* Broadwell */ case 0x2200 :/* Cherryview */ -return 8 ; +return 800 ;case 0x1900 :/* Skylake */ case 0x3100 :/* Gemini Lake */ case 0x5900 :/* Kaby Lake */ case 0x3e00 :/* Coffee Lake */ case 0x9B00 :/* Comet Lake */ -return 9 ; +return 900 ;case 0x8A00 :/* Ice Lake */ case 0x4500 :/* Elkhart Lake */ case 0x4E00 :/* Jasper Lake */ -return 11 ; +return 1100 ;case 0x9A00 :/* Tiger Lake */ case 0x4C00 :/* Rocket Lake */ case 0x4600 :/* Alder Lake */ case 0xA700 :/* Raptor Lake */ +return 1200 ;case 0x7D00 :/* Meteor Lake / Arrow Lake */ case 0xB600 :/* Arrow Lake */ -return 12 ; +return 1270 ; }/*
@@ -109,6 +111,12 @@ static int igd_gen(VFIOPCIDevice *vdev)return -1 ; } +static int igd_gen (VFIOPCIDevice *vdev) +{ +int ver =igd_graphics_ver (vdev); +return ver <0 ?-1 : ver /100 ; +} +#define IGD_ASLS 0xfc/* ASL Storage Register */ #define IGD_GMCH 0x50/* Graphics Control Register */ #define IGD_BDSM 0x5c/* Base Data of Stolen Memory */
@@ -458,10 +466,6 @@ static bool vfio_pci_igd_override_gms(int gen, uint32_t gms, uint32_t *gmch)#define IGD_BDSM_MMIO_OFFSET 0x1080C0#define IGD_MTL_PCODE_STOLEN_ACCESS 0x138914 -#define IGD_IS_MTL_OR_ARL (vdev) \ - ((((vdev)->device_id & 0xff00) == 0x7d00) || \ - (((vdev)->device_id & 0xff00) == 0xb600)) -static uint64_t vfio_igd_pcode_stolen_access_read (void *opaque,hwaddr addr,unsigned size) {
@@ -591,7 +595,7 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)* Return 0 for PCODE stolen memory access detection (0x138914) so GOP * stays on the standard access path in the VM. */ -if (IGD_IS_MTL_OR_ARL (vdev)) { +if (igd_graphics_ver (vdev) ==1270 ) { pcode_stolen_access_quirk =vfio_quirk_alloc (1 ); memory_region_init_io(pcode_stolen_access_quirk->mem, OBJECT(vdev), &vfio_igd_pcode_stolen_access_quirk, vdev,
Signature · 1 line
2.53.0
Quoted 19 lines · Tomita Moeko
Meteor Lake and Arrow Lake use graphics IP version 12.70, but
igd_gen()only returns the major version (generation). Encode the existing device ID mapping as (version * 100 + release) so that MTL/ARL can be selected in the BAR0 pcode stolen access quirk instead of a separate device ID check.Signed-off-by Tomita Moeko <[email protected]>Cc Yuan Wang <[email protected]>Cc Bosheng Xue <[email protected]>Cc Junjie Cao <[email protected]>--- hw/vfio/igd.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)hw/vfio/igd.c +0
-0
hw/vfio/igd.c line 60
Quoted 3 lines
hw/vfio/igd.c +0
-0@@ -58,8 +58,9 @@* not be taken as an indication that all the devices are supported, or even * supportable, some of them don't even support VT-d. * See linux:include/drm/i915_pciids.h for IDs.
This file doesn't exist.
Quoted 79 lines
hw/vfio/igd.c +16
-12+* Returns (version * 100 + release). */ -static int igd_gen (VFIOPCIDevice *vdev) +static int igd_graphics_ver (VFIOPCIDevice *vdev) {/* * Device IDs for Broxton/Apollo Lake are 0x0a84, 0x1a84, 0x1a85, 0x5a84 @@ -67,38 +68,39 @@ static int igd_gen(VFIOPCIDevice *vdev)* Prefix 0x0a is taken by Haswell, this rule should be matched first. */ if ((vdev->device_id &0xffe ) ==0xa84 ) { -return 9 ; +return 900 ; }switch (vdev->device_id &0xff00 ) {case 0x0100 :/* SandyBridge, IvyBridge */ -return 6 ; +return 600 ;case 0x0400 :/* Haswell */ case 0x0a00 :/* Haswell */ case 0x0c00 :/* Haswell */ case 0x0d00 :/* Haswell */ case 0x0f00 :/* Valleyview/Bay Trail */ -return 7 ; +return 700 ;case 0x1600 :/* Broadwell */ case 0x2200 :/* Cherryview */ -return 8 ; +return 800 ;case 0x1900 :/* Skylake */ case 0x3100 :/* Gemini Lake */ case 0x5900 :/* Kaby Lake */ case 0x3e00 :/* Coffee Lake */ case 0x9B00 :/* Comet Lake */ -return 9 ; +return 900 ;case 0x8A00 :/* Ice Lake */ case 0x4500 :/* Elkhart Lake */ case 0x4E00 :/* Jasper Lake */ -return 11 ; +return 1100 ;case 0x9A00 :/* Tiger Lake */ case 0x4C00 :/* Rocket Lake */ case 0x4600 :/* Alder Lake */ case 0xA700 :/* Raptor Lake */ +return 1200 ;case 0x7D00 :/* Meteor Lake / Arrow Lake */ case 0xB600 :/* Arrow Lake */ -return 12 ; +return 1270 ; }/* @@ -109,6 +111,12 @@ static int igd_gen(VFIOPCIDevice *vdev)return -1 ; } +static int igd_gen (VFIOPCIDevice *vdev) +{ +int ver =igd_graphics_ver (vdev); +return ver <0 ?-1 : ver /100 ; +} +#define IGD_ASLS 0xfc/* ASL Storage Register */ #define IGD_GMCH 0x50/* Graphics Control Register */ #define IGD_BDSM 0x5c/* Base Data of Stolen Memory */ @@ -458,10 +466,6 @@ static bool vfio_pci_igd_override_gms(int gen, uint32_t gms, uint32_t *gmch)#define IGD_BDSM_MMIO_OFFSET 0x1080C0#define IGD_MTL_PCODE_STOLEN_ACCESS 0x138914 -#define IGD_IS_MTL_OR_ARL (vdev) \ - ((((vdev)->device_id & 0xff00) == 0x7d00) || \ - (((vdev)->device_id & 0xff00) == 0xb600)) -static uint64_t vfio_igd_pcode_stolen_access_read (void *opaque,hwaddr addr,unsigned size) {
hw/vfio/igd.c void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) · line 598
Quoted 5 lines
hw/vfio/igd.c +1
-1@@ -591,7 +595,7 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)* Return 0 for PCODE stolen memory access detection (0x138914) so GOP * stays on the standard access path in the VM. */ -if (IGD_IS_MTL_OR_ARL (vdev)) { +if (igd_graphics_ver (vdev) ==1270 ) {
I'd prefer to introduce a define for this value. Anyhow,
hw/vfio/igd.c void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) · line 601
Quoted 3 lines
hw/vfio/igd.c +0
-0pcode_stolen_access_quirk =vfio_quirk_alloc (1 ); memory_region_init_io(pcode_stolen_access_quirk->mem, OBJECT(vdev), &vfio_igd_pcode_stolen_access_quirk, vdev,
Thanks,
C.