clear-pkgs-linux-iot-lts2018/1196-vhm-simplify-bdf_match...

50 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Liu Xinyun <xinyun.liu@intel.com>
Date: Thu, 21 Feb 2019 19:48:35 +0800
Subject: [PATCH] vhm: simplify bdf_match check
bdf was decoded already and no need to decode again
Tracked-On: projectacrn/acrn-hypervisor#2971
Signed-off-by: Liu Xinyun <xinyun.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
---
drivers/vhm/vhm_ioreq.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/vhm/vhm_ioreq.c b/drivers/vhm/vhm_ioreq.c
index 454ca9d1edcd..6dd5783f3aae 100644
--- a/drivers/vhm/vhm_ioreq.c
+++ b/drivers/vhm/vhm_ioreq.c
@@ -838,13 +838,14 @@ static int handle_cf8cfc(struct vhm_vm *vm, struct vhm_request *req, int vcpu)
return err ? err: req_handled;
}
-static bool bdf_match(struct vhm_vm *vm, struct ioreq_client *client)
+static bool bdf_match(struct vhm_request *req, struct ioreq_client *client)
{
int cached_bus, cached_dev, cached_func;
- cached_bus = (vm->pci_conf_addr >> 16) & PCI_BUSMAX;
- cached_dev = (vm->pci_conf_addr >> 11) & PCI_SLOTMAX;
- cached_func = (vm->pci_conf_addr >> 8) & PCI_FUNCMAX;
+ cached_bus = req->reqs.pci_request.bus;
+ cached_dev = req->reqs.pci_request.dev;
+ cached_func = req->reqs.pci_request.func;
+
return (client->trap_bdf &&
client->pci_bus == cached_bus &&
client->pci_dev == cached_dev &&
@@ -872,7 +873,7 @@ static struct ioreq_client *acrn_ioreq_find_client_by_request(struct vhm_vm *vm,
}
if (req->type == REQ_PCICFG) {
- if (bdf_match(vm, client)) { /* bdf match client */
+ if (bdf_match(req, client)) { /* bdf match client */
target_client = client->id;
break;
} else /* other or fallback client */
--
https://clearlinux.org