On 2016-12-05 13:54, Henning Schild wrote: > Match the device class and "protocol" while probing and skip unknow > devices. > > Signed-off-by: Henning Schild <[email protected]> > > diff --git a/inmates/demos/x86/ivshmem-demo.c > b/inmates/demos/x86/ivshmem-demo.c > --- a/inmates/demos/x86/ivshmem-demo.c > +++ b/inmates/demos/x86/ivshmem-demo.c > @@ -1,7 +1,7 @@ > /* > * Jailhouse, a Linux-based partitioning hypervisor > * > - * Copyright (c) Siemens AG, 2014 > + * Copyright (c) Siemens AG, 2014-2016 > * > * Authors: > * Henning Schild <[email protected]> > @@ -17,6 +17,8 @@ > #define IVSHMEM_CFG_SHMEM_PTR 0x40 > #define IVSHMEM_CFG_SHMEM_SZ 0x48 > > +#define JAILHOUSE_SHMEM_PROTO_UNDEFINED 0x0000 > + > #define IRQ_VECTOR 32 > > #define MAX_NDEV 4 > @@ -114,19 +116,26 @@ > { > int i; > int bdf = 0; > + unsigned int class_rev; > struct ivshmem_dev_data *d; > volatile char *shmem; > > int_init(); > > -again: > - bdf = pci_find_device(VENDORID, DEVICEID, bdf); > - if (bdf != -1) { > + while ((ndevices < MAX_NDEV) && > + (-1 != (bdf = pci_find_device(VENDORID, DEVICEID, bdf)))) { > printk("IVSHMEM: Found %04x:%04x at %02x:%02x.%x\n", > pci_read_config(bdf, PCI_CFG_VENDOR_ID, 2), > pci_read_config(bdf, PCI_CFG_DEVICE_ID, 2), > bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3); > - > + class_rev = pci_read_config(bdf, 0x8, 4); > + if (class_rev != (PCI_DEV_CLASS_OTHER << 24 | > + JAILHOUSE_SHMEM_PROTO_UNDEFINED << 8)) { > + printk("IVSHMEM: class/revision %08x, not supported " > + "skipping device\n", class_rev); > + bdf++; > + continue; > + } > ndevices++; > d = devs + ndevices - 1; > d->bdf = bdf; > @@ -139,8 +148,6 @@ > int_set_handler(IRQ_VECTOR + ndevices - 1, irq_handler); > pci_msix_set_vector(bdf, IRQ_VECTOR + ndevices - 1, 0); > bdf++; > - if (ndevices < MAX_NDEV) > - goto again; > } > > if (!ndevices) { > diff --git a/inmates/lib/x86/inmate.h b/inmates/lib/x86/inmate.h > --- a/inmates/lib/x86/inmate.h > +++ b/inmates/lib/x86/inmate.h > @@ -53,6 +53,8 @@ > > #define PCI_ID_ANY 0xffff > > +#define PCI_DEV_CLASS_OTHER 0xff > + > #define PCI_CAP_MSI 0x05 > #define PCI_CAP_MSIX 0x11 > >
Thanks, merged this and rebased patch 2 over next. Will post the underlying ivshmem fixes and refactorings soon. Jan -- Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux -- 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.
