WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH v3 03/10] xen: remap MSIs into pirqs when running

To: Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH v3 03/10] xen: remap MSIs into pirqs when running as initial domain
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Mon, 18 Oct 2010 11:46:03 -0400
Cc: Jeremy.Fitzhardinge@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Qing He <qing.he@xxxxxxxxx>, Yunhong Jiang <yunhong.jiang@xxxxxxxxx>
Delivery-date: Mon, 18 Oct 2010 08:47:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1286901770-8612-3-git-send-email-Stefano.Stabellini@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <alpine.DEB.2.00.1010121043030.2422@kaball-desktop> <1286901770-8612-3-git-send-email-Stefano.Stabellini@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
> +int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int 
> type)
> +{
> +     int irq = 0;

Lets make the default one -1, as that is the value we
are checking for errors later on.

> +     struct physdev_map_pirq map_irq;
> +     int rc;
> +     int pos;
> +     u32 table_offset, bir;
> +
> +     memset(&map_irq, 0, sizeof(map_irq));
> +     map_irq.domid = DOMID_SELF;
> +     map_irq.type = MAP_PIRQ_TYPE_MSI;
> +     map_irq.index = -1;
> +     map_irq.pirq = -1;
> +     map_irq.bus = dev->bus->number;
> +     map_irq.devfn = dev->devfn;
> +
> +     if (type == PCI_CAP_ID_MSIX) {
> +             pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
> +
> +             pci_read_config_dword(dev, msix_table_offset_reg(pos),
> +                                     &table_offset);
> +             bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
> +
> +             map_irq.table_base = pci_resource_start(dev, bir);
> +             map_irq.entry_nr = msidesc->msi_attrib.entry_nr;
> +     }
> +
> +     spin_lock(&irq_mapping_update_lock);
> +
> +     irq = find_unbound_irq();
> +
> +     if (irq == -1)
> +             goto out;
> +
> +     rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
> +     if (rc) {
> +             printk(KERN_WARNING "xen map irq failed %d\n", rc);
> +
> +             dynamic_irq_cleanup(irq);
> +
> +             irq = -1;
> +             goto out;
> +     }
> +     irq_info[irq] = mk_pirq_info(0, map_irq.pirq, 0, map_irq.index);
> +
> +     set_irq_chip_and_handler_name(irq, &xen_pirq_chip,
> +                     handle_level_irq,
> +                     (type == PCI_CAP_ID_MSIX) ? "msi-x":"msi");
> +
> +out:
> +     spin_unlock(&irq_mapping_update_lock);
> +     return irq;
> +}
> +#endif
> +
>  int xen_destroy_irq(int irq)
>  {
>       struct irq_desc *desc;
> diff --git a/include/xen/events.h b/include/xen/events.h
> index 0c58db6..8fa27dc 100644
> --- a/include/xen/events.h
> +++ b/include/xen/events.h
> @@ -72,8 +72,12 @@ void xen_hvm_evtchn_do_upcall(void);
>   * usual. */
>  int xen_allocate_pirq(unsigned gsi, int shareable, char *name);
>  int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name);
> +
> +#ifdef CONFIG_PCI_MSI
>  /* Allocate an irq and a pirq to be used with MSIs. */
>  void xen_allocate_pirq_msi(char *name, int *irq, int *pirq);
> +int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int 
> type);
> +#endif
>  
>  /* De-allocates the above mentioned physical interrupt. */
>  int xen_destroy_irq(int irq);
> -- 
> 1.5.6.5

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>