On 2016-11-30 17:50, 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
> @@ -114,6 +114,7 @@
>  {
>       int i;
>       int bdf = 0;
> +     unsigned int class_rev;
>       struct ivshmem_dev_data *d;
>       volatile char *shmem;
>  
> @@ -121,14 +122,19 @@
>  
>       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) {

Maybe explicitly state here that we are matching on
SHMEM_PROTO_UNDEFINED as well.

> +                     printk("IVSHMEM: class/revision %08x, not supported "
> +                            "skipping device\n", class_rev);
> +                     bdf++;
> +                     continue;
> +             }
>               ndevices++;
>               d = devs + ndevices - 1;
>               d->bdf = bdf;
> @@ -141,8 +147,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
>  
> 

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.

Reply via email to