From 86aa338a5f447c81dbc15f3142f2a294beaf7f0d Mon Sep 17 00:00:00 2001 From: Junming Liu Date: Thu, 26 Mar 2020 10:41:00 -0400 Subject: [PATCH] dm: correct PCI configures of igd-lpc previous patch fails to align SUBVID, SUBDID of igd-lpc with physical one. this patch corrects the errors and refine the code. Tracked-On: #4405 Signed-off-by: Junming Liu Signed-off-by: Shuo A Liu Acked-by: Wang, Yu1 --- devicemodel/hw/pci/lpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/devicemodel/hw/pci/lpc.c b/devicemodel/hw/pci/lpc.c index b9fb500dd..ca7cac9ef 100644 --- a/devicemodel/hw/pci/lpc.c +++ b/devicemodel/hw/pci/lpc.c @@ -495,11 +495,11 @@ pci_igd_lpc_init(struct vmctx *ctx, struct pci_vdev *pi, char *opts) * The VID, DID, REVID, SUBVID, SUBDID of igd-lpc need aligned with physical one. * Without these physical values, gvt-d GOP driver couldn't work. */ - pci_set_cfgdata16(pi, PCIR_DEVICE, (host_config[0x03] << 8) | host_config[0x02]); - pci_set_cfgdata16(pi, PCIR_VENDOR, (host_config[0x01] << 8) | host_config[0x00]); - pci_set_cfgdata8(pi, PCIR_REVID, host_config[0x08]); - pci_set_cfgdata16(pi, PCIR_SUBVEND_0, (host_config[0x01] << 8) | host_config[0x00]); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, (host_config[0x03] << 8) | host_config[0x02]); + pci_set_cfgdata16(pi, PCIR_DEVICE, *(uint16_t *)(host_config + PCIR_DEVICE)); + pci_set_cfgdata16(pi, PCIR_VENDOR, *(uint16_t *)(host_config + PCIR_VENDOR)); + pci_set_cfgdata8(pi, PCIR_REVID, host_config[PCIR_REVID]); + pci_set_cfgdata16(pi, PCIR_SUBVEND_0, *(uint16_t *)(host_config + PCIR_SUBVEND_0)); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, *(uint16_t *)(host_config + PCIR_SUBDEV_0)); return 0; }