Cache the matching BDF of the peer in the ivshmem_data structure. This
will help us when we no longer require slot 0 to be in use.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/ivshmem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
index f06622b..cd6632e 100644
--- a/hypervisor/ivshmem.c
+++ b/hypervisor/ivshmem.c
@@ -50,6 +50,7 @@
 
 struct ivshmem_data {
        struct ivshmem_endpoint eps[2];
+       u16 bdf;
        struct ivshmem_data *next;
 };
 
@@ -239,12 +240,10 @@ static int ivshmem_write_msix_control(struct 
ivshmem_endpoint *ive, u32 val)
 static struct ivshmem_data **ivshmem_find(struct pci_device *d, int *cellnum)
 {
        struct ivshmem_data **ivp, *iv;
-       u16 bdf2;
 
        for (ivp = &ivshmem_list; *ivp; ivp = &((*ivp)->next)) {
                iv = *ivp;
-               bdf2 = iv->eps[0].device->info->bdf;
-               if (d->info->bdf == bdf2) {
+               if (d->info->bdf == iv->bdf) {
                        if (iv->eps[0].device == d) {
                                if (cellnum)
                                        *cellnum = 0;
@@ -419,6 +418,7 @@ int ivshmem_init(struct cell *cell, struct pci_device 
*device)
        *ivp = page_alloc(&mem_pool, 1);
        if (!(*ivp))
                return -ENOMEM;
+       (*ivp)->bdf = device->info->bdf;
        ivshmem_connect_cell(*ivp, device, mem, 0);
 
 connected:
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to