[PATCH PV_OPS PCIBACK]
PATCH 1/1 [PATCH PV_OPS PCIBACK]
In these following patches:
[PATCH 1/5] xenbus_walk - walk XenStore keys, calling callback. [PATCH 2/5] In xen_create_msi_irq, extract the domain id of the MSI device.
We employ an mechanism (as compared to 2.6.18), to extract the domain id of the non-privileged domain. Specifically we enumerate the XenStore keys and if a match is found we can extract the domain id. With the domain id we can make the Xen-HYPERCALL to set the "owner" of the MSI device.
The next patches:
[PATCH 3/5] Add MSI capability to the pciback driver.
[PATCH 4/5] Return the physical IRQ number instead of the allocated IRQ number to pcifront.
Copy-n-paste the MSI support from 2.6.18 and augment it to return the proper IRQ number to the pcifront.
The last patch:
[PATCH 5/5] Fix checkpatch warnings and errors for pciback/ directory.
is just to have a clean base for futher work.
And the diffstat of all the changes:
drivers/xen/events.c | 53 +++++++- drivers/xen/pciback/Makefile | 1 + drivers/xen/pciback/conf_space.c | 34 ++-- drivers/xen/pciback/conf_space.h | 30 ++-- drivers/xen/pciback/conf_space_capability.c | 5 +- drivers/xen/pciback/conf_space_capability.h | 3 + drivers/xen/pciback/conf_space_capability_msi.c | 84 +++++++++++ drivers/xen/pciback/conf_space_capability_pm.c | 4 +- drivers/xen/pciback/conf_space_capability_vpd.c | 2 +- drivers/xen/pciback/conf_space_header.c | 7 +- drivers/xen/pciback/conf_space_quirks.c | 16 +- drivers/xen/pciback/controller.c | 15 +- drivers/xen/pciback/passthrough.c | 6 +- drivers/xen/pciback/pci_stub.c | 180 ++++++++++++----------- drivers/xen/pciback/pciback.h | 34 ++++- drivers/xen/pciback/pciback_ops.c | 64 +++++---- drivers/xen/pciback/slot.c | 22 ++- drivers/xen/pciback/vpci.c | 28 ++-- drivers/xen/pciback/xenbus.c | 42 +++--- drivers/xen/xenbus/xenbus_xs.c | 130 ++++++++++++++++ include/xen/xenbus.h | 2 + 21 files changed, 538 insertions(+), 224 deletions(-)
PATCH 1/5 xenbus_walk - walk XenStore keys, calling callback.
This is quite similar to 'pci_walk_bus.' We walk the XenStore keys, starting at the initial path, calling the callback with each key that has a value. If the callback returns a negative value we stop, clean up, and return the value back.
--- drivers/xen/xenbus/xenbus_xs.c | 130 ++++++++++++++++++++++++++++++++++++++++ include/xen/xenbus.h | 2 + 2 files changed, 132 insertions(+), 0 deletions(-)
drivers/xen/xenbus/xenbus_xs.c +130 -0
@@ -67,6 +67,13 @@ struct xs_stored_msg { } u; }; +/* Temporary structure used by xenbus_walk to collect all of the +* paths in a stack for traversing. */ +struct xs_data_tuple { +struct list_head list; +char *path; +}; +struct xs_handle {/* A list of replies. Currently only one will ever be outstanding. */ struct list_head reply_list;
@@ -111,6 +118,35 @@ static pid_t xenwatch_pid;static DEFINE_MUTEX (xenwatch_mutex);static DECLARE_WAIT_QUEUE_HEAD (watch_events_waitq); +static struct xs_data_tuple *add_tuple (struct list_head *list,char *path) +{ +struct xs_data_tuple *data; + + data =kzalloc (sizeof (struct xs_data_tuple ),GFP_KERNEL ); +if (!data) { +printk (KERN_ERR "%s: could not allocate memory\n" , __func__); +return NULL ; + } + + data->path = path; +list_add_tail (&data->list, list); + +return data; +} + +static int free_tuple (struct xs_data_tuple *data) +{ + +if (!data) +return 0 ; + +kfree (data->path); + +kfree (data); +return 0 ; +} + +static int get_error (const char *errorstring) {unsigned int i;
@@ -367,6 +403,100 @@ void *xenbus_read(struct xenbus_transaction t, }EXPORT_SYMBOL_GPL (xenbus_read); + +/* +* A traverse of XenStore directory using a stack based +* implementation. For each file the callback function +* is called with: +* cb(path, filename, value, userdata); +* +* Zero return value continues the walk, while any other +* exits and returns the value. The value passed in the callback +* are automatically free-d. +* +*/ +int xenbus_walk (char *start_path, +int (*cb)(char *,char *,char *,void *), +void *userdata) +{ + +struct list_head list; +struct xs_data_tuple *tuple, *tmp; +char **dir; +char *newpath, *val; +unsigned int i, dir_n; +int rc =0 ; + +if (!cb) +return -ENONET ; + +if (!xenstored_ready) +return -EBUSY ; + +INIT_LIST_HEAD (&list); + +/* Item added to the top. */ + newpath =kasprintf (GFP_KERNEL ,"%s" , start_path); +if (!add_tuple (&list, newpath)) + goto err_start; + + tuple = list_entry(&list, struct xs_data_tuple, list); +while (!list_empty (&list) && !rc) { +/* Pop first element. */ + tuple = list_entry(list.next, struct xs_data_tuple, list); +if (!tuple) + goto err_while; +list_del (&tuple->list); +/* And start listening 'em. */ + dir =xenbus_directory (XBT_NIL , tuple->path,"" , &dir_n); +if (IS_ERR (dir)) { +/* This will happen on XenStore directories we don't +* have access to. (Like for other domains).*/ +free_tuple (tuple); +continue ; + } +for (i =0 ; i < dir_n; i++) { +if (tuple->path && + tuple->path[strlen (tuple->path)-1 ] !='/' ) { + val =xenbus_read (XBT_NIL , tuple->path, dir[i], +NULL ); +if (!IS_ERR (val)) { +/* Same thing as with xenbus_directory. +* Some values are protected.*/ + rc =cb (tuple->path, dir[i], + val, userdata); +kfree (val); + } + } +if (rc) +break ; + newpath =kasprintf (GFP_KERNEL ,"%s%s%s" , tuple->path, + tuple->path[strlen (tuple->path)-1 ] == +'/' ?"" :"/" , + dir[i]); + +if (!newpath) + goto err_loop; +if (!add_tuple (&list, newpath)) + goto err_loop; + } +kfree (dir); +free_tuple (tuple); + } + goto err_while; +err_loop: +kfree (dir); +err_start: +kfree (newpath); +err_while: +list_for_each_entry_safe (tuple, tmp, &list, list) { +list_del (&tuple->list); +free_tuple (tuple); + } +return rc; +} +EXPORT_SYMBOL_GPL (xenbus_walk); +/* Write the value of a single file. * Returns -err on failure. */
include/xen/xenbus.h +2 -0
@@ -229,4 +229,6 @@ const char *xenbus_strstate(enum xenbus_state state);int xenbus_dev_is_online (struct xenbus_device *dev);int xenbus_frontend_closed (struct xenbus_device *dev); +int xenbus_walk (char *start_path,int (*cb)(char *,char *,char *,void *), +void *userdata);#endif /* _XEN_XENBUS_H */
Signature · 1 line
1.6.2.5
PATCH 2/5 In xen_create_msi_irq, extract the domain id of the MSI device.
We walk the XenStore keys to see if there is a matching PCI device
that is assigned to a non-privileged PV domain (that uses the pciback module). If so, we extract the domain id and use that for to map the IPI for the MSI
to the correct guest.
--- drivers/xen/events.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 51 insertions(+), 2 deletions(-)
drivers/xen/events.c +51 -2
@@ -45,6 +45,7 @@#include <xen/interface/xen.h> #include <xen/interface/event_channel.h> +#include <xen/xenbus.h> #include "../pci/msi.h" /*
@@ -92,6 +93,7 @@ struct irq_infounsigned short nr;unsigned char vector;unsigned char flags; +domid_t domid; } pirq; } u; };
@@ -148,7 +150,8 @@ static struct irq_info mk_pirq_info(unsigned short evtchn, unsigned short pirq, unsigned short vector) { return (struct irq_info) { .type = IRQT_PIRQ, .evtchn = evtchn, - .cpu = 0, .u.pirq = { .nr = pirq, .vector = vector } }; + .cpu = 0, .u.pirq = + { .nr = pirq, .vector = vector, .domid = DOMID_SELF } }; }/*
@@ -595,7 +598,7 @@ int xen_destroy_irq(int irq) goto out; unmap_irq.pirq = info->u.pirq.nr; - unmap_irq.domid =DOMID_SELF ; + unmap_irq.domid = info->u.pirq.domid; rc =HYPERVISOR_physdev_op (PHYSDEVOP_unmap_pirq, &unmap_irq);if (rc) {printk (KERN_WARNING "unmap irq failed %d\n" , rc);
@@ -610,6 +613,43 @@ out:spin_unlock (&irq_mapping_update_lock);return rc; } +#define XS_PCI_SEARCH "/local/domain/0/backend/pci/" +#define XS_PCI_SEARCH_LEN 28 + +static int get_domid_for_dev (char *nodename,char *path,char *val,void *data) +{ +struct pci_dev *dev = (struct pci_dev *)data; + +/* We are looking for: +* CB inv[/local/domain/0/backend/pci/3/0/dev-1]=0000:00:14.5 */ + +if (!dev || !pci_name (dev)) +return -ENODEV ; + +if (strncmp (nodename,XS_PCI_SEARCH ,XS_PCI_SEARCH_LEN ) ==0 ) + { +if (strncmp (path,"dev" ,3 ) ==0 ) { +char *name =NULL ; +unsigned int domid; + +/* The val contains: 0000:00:14.5 */ +if (strcmp (val,pci_name (dev)) !=0 ) +return 0 ; + +/* From here on, extract the Domain ID */ + name =strstr (nodename,"pci/" ); +if (!name) +return 0 ; + +if (sscanf (name,"pci/%u" , &domid) !=1 ) +return 0 ; + +dev_dbg (&dev->dev,"Assigned to domain %u.\n" , domid); +return domid; + } + } +return 0 ; +}int xen_create_msi_irq (struct pci_dev *dev,struct msi_desc *msidesc,int type) {
@@ -620,6 +660,12 @@ int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type)int pos;u32 table_offset, bir; +/* Walk the XenStore keys to see if the device is assigned to any +* domain. If so, extract the domain id. */ + domid = rc =xenbus_walk ("/local/domain/0" , get_domid_for_dev, dev); +if (domid <=0 ) + domid =DOMID_SELF ; +memset (&map_irq,0 ,sizeof (map_irq)); map_irq.domid = domid; map_irq.type =MAP_PIRQ_TYPE_MSI ;
@@ -658,6 +704,9 @@ int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type) } irq_info[irq] =mk_pirq_info (0 , map_irq.pirq, map_irq.index); +if (domid) + irq_info[irq].u.pirq.domid = domid; +set_irq_chip_and_handler_name (irq, &xen_pirq_chip, handle_level_irq, (type ==PCI_CAP_ID_MSIX ) ?"msi-x" :"msi" );
Signature · 1 line
1.6.2.5
PATCH 3/5 Add MSI capability to the pciback driver.
This is a reverse commit of a previous patch that disabled the functionality. It is essentially a copy of the MSI functionality from the linux-2.6.18.hg tree.
--- drivers/xen/pciback/Makefile | 1 + drivers/xen/pciback/conf_space_capability_msi.c | 79 +++++++++++++++++++++++ drivers/xen/pciback/pci_stub.c | 15 ++++ drivers/xen/pciback/pciback.h | 14 ++++ drivers/xen/pciback/pciback_ops.c | 14 ++++ 5 files changed, 123 insertions(+), 0 deletions(-) create mode 100644 drivers/xen/pciback/conf_space_capability_msi.c
drivers/xen/pciback/Makefile +1 -0
@@ -6,6 +6,7 @@ pciback-y += conf_space.o conf_space_header.o \ conf_space_capability_vpd.o \ conf_space_capability_pm.o \ conf_space_quirks.o +pciback-$(CONFIG_PCI_MSI) += conf_space_capability_msi.o pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o pciback-$(CONFIG_XEN_PCIDEV_BACKEND_SLOT) += slot.o pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
drivers/xen/pciback/conf_space_capability_msi.c new file +79 -0
79 lines not on this page · raw message
drivers/xen/pciback/pci_stub.c +15 -0
@@ -1173,6 +1173,21 @@ static ssize_t permissive_show(struct device_driver *drv, char *buf)DRIVER_ATTR (permissive,S_IRUSR |S_IWUSR , permissive_show, permissive_add); +#ifdef CONFIG_PCI_MSI + +int pciback_get_owner (struct pci_dev *dev) +{ +struct pcistub_device *psdev; + + psdev =pcistub_device_find (pci_domain_nr (dev->bus), dev->bus->number, +PCI_SLOT (dev->devfn),PCI_FUNC (dev->devfn)); + +if (!psdev || !psdev->pdev) +return -1 ; + +return psdev->pdev->xdev->otherend_id; +} +#endif static void pcistub_exit (void ) {
drivers/xen/pciback/pciback.h +14 -0
@@ -104,6 +104,20 @@ void pciback_do_op(struct work_struct *data);int pciback_xenbus_register (void );void pciback_xenbus_unregister (void ); +#ifdef CONFIG_PCI_MSI +int pciback_enable_msi (struct pciback_device *pdev, +struct pci_dev *dev,struct xen_pci_op *op); + +int pciback_disable_msi (struct pciback_device *pdev, +struct pci_dev *dev,struct xen_pci_op *op); + + +int pciback_enable_msix (struct pciback_device *pdev, +struct pci_dev *dev,struct xen_pci_op *op); + +int pciback_disable_msix (struct pciback_device *pdev, +struct pci_dev *dev,struct xen_pci_op *op); +#endif extern int verbose_request;void test_and_schedule_op (struct pciback_device *pdev);
drivers/xen/pciback/pciback_ops.c +14 -0
@@ -89,6 +89,20 @@ void pciback_do_op(struct work_struct *data) op->err =pciback_config_write (dev, op->offset, op->size, op->value);break ; +#ifdef CONFIG_PCI_MSI +case XEN_PCI_OP_enable_msi: + op->err =pciback_enable_msi (pdev, dev, op); +break ; +case XEN_PCI_OP_disable_msi: + op->err =pciback_disable_msi (pdev, dev, op); +break ; +case XEN_PCI_OP_enable_msix: + op->err =pciback_enable_msix (pdev, dev, op); +break ; +case XEN_PCI_OP_disable_msix: + op->err =pciback_disable_msix (pdev, dev, op); +break ; +#endif default : op->err = XEN_PCI_ERR_not_implemented;break ;
Signature · 1 line
1.6.2.5
PATCH 4/5 Return the physical IRQ number instead of the allocated IRQ number to pcifront.
The allocation of IRQ numbers in Linux privileged domains is based on finding the first unbound IRQ number. After the allocation is done a HYPERCALL to Xen is done, which allocates a PIRQ globally. That PIRQ->IRQ binding is saved in data structures that are used during ISR executions.
Before this patch, for non-privileged domains we would return the local IRQ number instead of the PIRQ. The non-privileged domains require the PIRQ so that they can attach the their own interrupt handler to it. Fortunatly there is a function, 'xen_gsi_from_irq' that returns that global IRQ number.
This has been succesfully tested with MSI devices. I hadn't tested it with MSI-X yet.
--- drivers/xen/pciback/conf_space_capability_msi.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/xen/pciback/conf_space_capability_msi.c +8 -4
@@ -6,6 +6,7 @@#include "conf_space.h" #include "conf_space_capability.h" #include <xen/interface/io/pciif.h> +#include <xen/events.h> #include "pciback.h" int pciback_enable_msi(struct pciback_device *pdev,
@@ -22,7 +23,9 @@ int pciback_enable_msi(struct pciback_device *pdev,return XEN_PCI_ERR_op_failed; } - op->value = dev->irq; +/* The value the guest needs is actually the IDT vector, not the +* the local domain's IRQ number. */ + op->value =xen_gsi_from_irq (dev->irq);return 0 ; }
@@ -31,7 +34,7 @@ int pciback_disable_msi(struct pciback_device *pdev, {pci_disable_msi (dev); - op->value = dev->irq; + op->value =xen_gsi_from_irq (dev->irq);return 0 ; }
@@ -57,7 +60,8 @@ int pciback_enable_msix(struct pciback_device *pdev,for (i =0 ; i < op->value; i++) { op->msix_entries[i].entry = entries[i].entry; - op->msix_entries[i].vector = entries[i].vector; + op->msix_entries[i].vector = +xen_gsi_from_irq (entries[i].vector); }kfree (entries);
@@ -73,7 +77,7 @@ int pciback_disable_msix(struct pciback_device *pdev,pci_disable_msix (dev); - op->value = dev->irq; + op->value =xen_gsi_from_irq (dev->irq);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 5/5 Fix checkpatch warnings and errors for pciback/ directory.
--- drivers/xen/pciback/conf_space.c | 34 +++--- drivers/xen/pciback/conf_space.h | 30 ++-- drivers/xen/pciback/conf_space_capability.c | 5 +- drivers/xen/pciback/conf_space_capability.h | 3 + drivers/xen/pciback/conf_space_capability_msi.c | 3 +- drivers/xen/pciback/conf_space_capability_pm.c | 4 +- drivers/xen/pciback/conf_space_capability_vpd.c | 2 +- drivers/xen/pciback/conf_space_header.c | 7 +- drivers/xen/pciback/conf_space_quirks.c | 16 ++- drivers/xen/pciback/controller.c | 15 +- drivers/xen/pciback/passthrough.c | 6 +- drivers/xen/pciback/pci_stub.c | 165 +++++++++++------------ drivers/xen/pciback/pciback.h | 28 +++-- drivers/xen/pciback/pciback_ops.c | 74 +++++------ drivers/xen/pciback/slot.c | 22 ++-- drivers/xen/pciback/vpci.c | 28 ++-- drivers/xen/pciback/xenbus.c | 42 +++--- 17 files changed, 245 insertions(+), 239 deletions(-)
drivers/xen/pciback/conf_space.c +17 -17
@@ -18,11 +18,11 @@static int permissive;module_param (permissive, bool,0644 ); -#define DEFINE_PCI_CONFIG (op,size,type) \ +#define DEFINE_PCI_CONFIG (op, size, type) \ int pciback_##op##_config_##size \ (struct pci_dev *dev, int offset, type value, void *data) \ { \ - return pci_##op##_config_##size (dev, offset, value); \ + return pci_##op##_config_##size(dev, offset, value); \ } DEFINE_PCI_CONFIG(read, byte, u8 *)
@@ -139,14 +139,15 @@ static int pcibios_err_to_errno(int err) }int pciback_config_read (struct pci_dev *dev,int offset,int size, -u32 * ret_val) +u32 *ret_val) {int err =0 ;struct pciback_dev_data *dev_data =pci_get_drvdata (dev);const struct config_field_entry *cfg_entry;const struct config_field *field;int req_start, req_end, field_start, field_end; -/* if read fails for any reason, return 0 (as if device didn't respond) */ +/* if read fails for any reason, return 0 +* (as if device didn't respond) */ u32 value =0 , tmp_val;if (unlikely (verbose_request))
@@ -161,10 +162,10 @@ int pciback_config_read(struct pci_dev *dev, int offset, int size,/* Get the real value first, then modify as appropriate */ switch (size) {case 1 : - err =pci_read_config_byte (dev, offset, (u8 *) & value); + err =pci_read_config_byte (dev, offset, (u8 *) &value);break ;case 2 : - err =pci_read_config_word (dev, offset, (u16 *) & value); + err =pci_read_config_word (dev, offset, (u16 *) &value);break ;case 4 : err =pci_read_config_dword (dev, offset, &value);
@@ -192,7 +193,7 @@ int pciback_config_read(struct pci_dev *dev, int offset, int size, } } - out: +out:if (unlikely (verbose_request))printk (KERN_DEBUG "pciback: %s: read %d bytes at 0x%x = %x\n" ,pci_name (dev), size, offset, value);
@@ -276,8 +277,8 @@ int pciback_config_write(struct pci_dev *dev, int offset, int size, u32 value) }else if (!dev_data->warned_on_write) { dev_data->warned_on_write =1 ;dev_warn (&dev->dev,"Driver tried to write to a " -"read-only configuration space field at offset " -"0x%x, size %d. This may be harmless, but if " +"read-only configuration space field at offset" +" 0x%x, size %d. This may be harmless, but if " "you have problems with your device:\n" "1) see permissive attribute in sysfs\n" "2) report problems to the xen-devel "
@@ -295,8 +296,8 @@ void pciback_config_free_dyn_fields(struct pci_dev *dev)struct config_field_entry *cfg_entry, *t;const struct config_field *field; -dev_dbg (&dev->dev, -"free-ing dynamically allocated virtual configuration space fields\n" ); +dev_dbg (&dev->dev,"free-ing dynamically allocated virtual " +"configuration space fields\n" );if (!dev_data)return ;
@@ -306,8 +307,7 @@ void pciback_config_free_dyn_fields(struct pci_dev *dev)if (field->clean) { field->clean ((struct config_field *)field); -if (cfg_entry->data) -kfree (cfg_entry->data); +kfree (cfg_entry->data);list_del (&cfg_entry->list);kfree (cfg_entry);
@@ -376,7 +376,7 @@ int pciback_config_add_field_offset(struct pci_dev *dev, cfg_entry->base_offset = base_offset;/* silently ignore duplicate fields */ - err =pciback_field_is_dup (dev,OFFSET (cfg_entry)); + err =pciback_field_is_dup (dev,OFFSET (cfg_entry));if (err) goto out;
@@ -395,14 +395,14 @@ int pciback_config_add_field_offset(struct pci_dev *dev, OFFSET(cfg_entry));list_add_tail (&cfg_entry->list, &dev_data->config_fields); - out: +out:if (err)kfree (cfg_entry);return err; } -/* This sets up the device's virtual configuration space to keep track of +/* This sets up the device's virtual configuration space to keep track of * certain registers (like the base address registers (BARs) so that we can * keep the client from manipulating them directly. */
@@ -425,7 +425,7 @@ int pciback_config_init_dev(struct pci_dev *dev) err =pciback_config_quirks_init (dev); - out: +out:return err; }
drivers/xen/pciback/conf_space.h +15 -15
@@ -11,21 +11,21 @@#include <linux/err.h> /* conf_field_init can return an errno in a ptr with ERR_PTR() */ -typedef void *(*conf_field_init ) (struct pci_dev * dev,int offset); -typedef void (*conf_field_reset ) (struct pci_dev * dev,int offset,void *data); -typedef void (*conf_field_free ) (struct pci_dev * dev,int offset,void *data); +typedef void *(*conf_field_init ) (struct pci_dev *dev,int offset); +typedef void (*conf_field_reset ) (struct pci_dev *dev,int offset,void *data); +typedef void (*conf_field_free ) (struct pci_dev *dev,int offset,void *data); -typedef int (*conf_dword_write ) (struct pci_dev * dev,int offset,u32 value, +typedef int (*conf_dword_write ) (struct pci_dev *dev,int offset,u32 value,void *data); -typedef int (*conf_word_write ) (struct pci_dev * dev,int offset,u16 value, +typedef int (*conf_word_write ) (struct pci_dev *dev,int offset,u16 value,void *data); -typedef int (*conf_byte_write ) (struct pci_dev * dev,int offset,u8 value, +typedef int (*conf_byte_write ) (struct pci_dev *dev,int offset,u8 value,void *data); -typedef int (*conf_dword_read ) (struct pci_dev * dev,int offset,u32 * value, +typedef int (*conf_dword_read ) (struct pci_dev *dev,int offset,u32 *value,void *data); -typedef int (*conf_word_read ) (struct pci_dev * dev,int offset,u16 * value, +typedef int (*conf_word_read ) (struct pci_dev *dev,int offset,u16 *value,void *data); -typedef int (*conf_byte_read ) (struct pci_dev * dev,int offset,u8 * value, +typedef int (*conf_byte_read ) (struct pci_dev *dev,int offset,u8 *value,void *data);/* These are the fields within the configuration space which we
@@ -39,7 +39,7 @@ struct config_field {conf_field_init init;conf_field_reset reset;conf_field_free release; -void (*clean) (struct config_field * field); +void (*clean) (struct config_field *field); union { struct { conf_dword_write write;
@@ -92,8 +92,8 @@ static inline int pciback_config_add_fields(struct pci_dev *dev, }static inline int pciback_config_add_fields_offset (struct pci_dev *dev, -const struct config_field *field, -unsigned int offset) +const struct config_field *field, +unsigned int offset) {int i, err =0 ;for (i =0 ; field[i].size !=0 ; i++) {
@@ -105,11 +105,11 @@ static inline int pciback_config_add_fields_offset(struct pci_dev *dev, }/* Read/Write the real configuration space */ -int pciback_read_config_byte (struct pci_dev *dev,int offset,u8 * value, +int pciback_read_config_byte (struct pci_dev *dev,int offset,u8 *value,void *data); -int pciback_read_config_word (struct pci_dev *dev,int offset,u16 * value, +int pciback_read_config_word (struct pci_dev *dev,int offset,u16 *value,void *data); -int pciback_read_config_dword (struct pci_dev *dev,int offset,u32 * value, +int pciback_read_config_dword (struct pci_dev *dev,int offset,u32 *value,void *data);int pciback_write_config_byte (struct pci_dev *dev,int offset,u8 value,void *data);
drivers/xen/pciback/conf_space_capability.c +1 -4
@@ -53,13 +53,10 @@ int pciback_config_capability_add_fields(struct pci_dev *dev) } } - out: +out:return err; } -extern struct pciback_config_capability pciback_config_capability_vpd; -extern struct pciback_config_capability pciback_config_capability_pm; -int pciback_config_capability_init (void ) {register_capability (&pciback_config_capability_vpd);
drivers/xen/pciback/conf_space_capability.h +3 -0
@@ -20,4 +20,7 @@ struct pciback_config_capability { const struct config_field *fields; }; +extern struct pciback_config_capability pciback_config_capability_vpd; +extern struct pciback_config_capability pciback_config_capability_pm; +#endif
drivers/xen/pciback/conf_space_capability_msi.c +2 -1
@@ -18,7 +18,8 @@ int pciback_enable_msi(struct pciback_device *pdev, status =pci_enable_msi (dev);if (status) { -printk ("error enable msi for guest %x status %x\n" , otherend, status); +printk (KERN_ERR "error enable msi for guest %x status %x\n" , + otherend, status); op->value =0 ;return XEN_PCI_ERR_op_failed; }
drivers/xen/pciback/conf_space_capability_pm.c +2 -2
@@ -20,7 +20,7 @@ static int pm_caps_read(struct pci_dev *dev, int offset, u16 *value, *value = real_value & ~PCI_PM_CAP_PME_MASK ; - out: +out:return err; }
@@ -77,7 +77,7 @@ static void *pm_ctrl_init(struct pci_dev *dev, int offset) err =pci_write_config_word (dev, offset, value); } - out: +out:return ERR_PTR (err); }
drivers/xen/pciback/conf_space_capability_vpd.c +1 -1
@@ -33,7 +33,7 @@ static const struct config_field caplist_vpd[] = { }, {} }; - +struct pciback_config_capability pciback_config_capability_vpd = { .capability =PCI_CAP_ID_VPD , .fields = caplist_vpd,
drivers/xen/pciback/conf_space_header.c +4 -3
@@ -51,7 +51,8 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data) err =pci_set_mwi (dev);if (err) {printk (KERN_WARNING -"pciback: %s: cannot enable memory-write-invalidate (%d)\n" , +"pciback: %s: cannot enable " +"memory-write-invalidate (%d)\n" ,pci_name (dev), err); value &= ~PCI_COMMAND_INVALIDATE ; }
@@ -206,7 +207,7 @@ static int bist_write(struct pci_dev *dev, int offset, u8 value, void *data) || value == PCI_BIST_START) err =pci_write_config_byte (dev, offset, value); - out: +out:return err; }
@@ -312,6 +313,6 @@ int pciback_config_header_add_fields(struct pci_dev *dev)break ; } - out: +out:return err; }
drivers/xen/pciback/conf_space_quirks.c +9 -7
@@ -18,8 +18,10 @@ match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) {if ((id->vendor ==PCI_ANY_ID || id->vendor == dev->vendor) && (id->device ==PCI_ANY_ID || id->device == dev->device) && - (id->subvendor ==PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && - (id->subdevice ==PCI_ANY_ID || id->subdevice == dev->subsystem_device) && + (id->subvendor ==PCI_ANY_ID || + id->subvendor == dev->subsystem_vendor) && + (id->subdevice ==PCI_ANY_ID || + id->subdevice == dev->subsystem_device) && !((id->class ^ dev->class) & id->class_mask))return id;return NULL ;
@@ -35,7 +37,7 @@ struct pciback_config_quirk *pciback_find_quirk(struct pci_dev *dev) tmp_quirk =NULL ;printk (KERN_DEBUG "quirk didn't match any device pciback knows about\n" ); - out: +out:return tmp_quirk; }
@@ -51,7 +53,7 @@ int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg)struct config_field_entry *cfg_entry;list_for_each_entry (cfg_entry, &dev_data->config_fields, list) { -if (OFFSET (cfg_entry) == reg) { +if (OFFSET (cfg_entry) == reg) { ret =1 ;break ; }
@@ -84,7 +86,7 @@ int pciback_config_quirks_add_field(struct pci_dev *dev, struct config_fieldpciback_config_add_field (dev, field); - out: +out:return err; }
@@ -110,7 +112,7 @@ int pciback_config_quirks_init(struct pci_dev *dev) quirk->pdev = dev;register_quirk (quirk); - out: +out:return ret; }
@@ -133,6 +135,6 @@ int pciback_config_quirk_release(struct pci_dev *dev)list_del (&quirk->quirks_list);kfree (quirk); - out: +out:return ret; }
drivers/xen/pciback/controller.c +7 -8
@@ -259,7 +259,7 @@ static acpi_status write_xenbus_resource(struct acpi_resource *res, void *data) !(addr.resource_type == ACPI_IO_RANGE && addr.info.io.translation))return AE_OK ; - +/* Store the resource in xenbus for the guest */ len =snprintf (str,sizeof (str),"root-%d-resource-%d" , info->root_num, info->resource_count);
@@ -314,7 +314,7 @@ int pciback_publish_pci_roots(struct pciback_device *pdev, goto out;/* -* Now figure out which root-%d this belongs to +* Now figure out which root-%d this belongs to * so we can associate resources with it. */ err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
@@ -407,8 +407,8 @@ void pciback_release_devices(struct pciback_device *pdev) pdev->pci_dev_data =NULL ; } -int pciback_get_pcifront_dev (struct pci_dev *pcidev, -struct pciback_device *pdev, +int pciback_get_pcifront_dev (struct pci_dev *pcidev, +struct pciback_device *pdev,unsigned int *domain,unsigned int *bus,unsigned int *devfn) {struct controller_dev_data *dev_data = pdev->pci_dev_data;
@@ -420,13 +420,12 @@ int pciback_get_pcifront_dev(struct pci_dev *pcidev,list_for_each_entry (cntrl_entry, &dev_data->list, list) {list_for_each_entry (dev_entry, &cntrl_entry->dev_list, list) { -if ( (dev_entry->dev->bus->number == +if ((dev_entry->dev->bus->number == pcidev->bus->number) && - (dev_entry->dev->devfn == + (dev_entry->dev->devfn == pcidev->devfn) && (pci_domain_nr (dev_entry->dev->bus) == -pci_domain_nr (pcidev->bus))) - { +pci_domain_nr (pcidev->bus))) { found =1 ; *domain = cntrl_entry->domain; *bus = cntrl_entry->bus;
drivers/xen/pciback/passthrough.c +4 -2
@@ -165,8 +165,10 @@ void pciback_release_devices(struct pciback_device *pdev) pdev->pci_dev_data =NULL ; } -int pciback_get_pcifront_dev (struct pci_dev *pcidev,struct pciback_device *pdev, -unsigned int *domain,unsigned int *bus,unsigned int *devfn) +int pciback_get_pcifront_dev (struct pci_dev *pcidev, +struct pciback_device *pdev, +unsigned int *domain,unsigned int *bus, +unsigned int *devfn) { *domain =pci_domain_nr (pcidev->bus);
drivers/xen/pciback/pci_stub.c +78 -87
439 lines not on this page · raw message
drivers/xen/pciback/pciback.h +18 -10
@@ -49,6 +49,12 @@ struct pciback_dev_data {int warned_on_write; }; +/* Used by XenBus and pciback_ops.c */ +extern wait_queue_head_t aer_wait_queue; +extern struct workqueue_struct *pciback_wq; +/* Used by pcistub.c and conf_space_quirks.c */ +extern struct list_head pciback_quirks; +/* Get/Put PCI Devices that are hidden from the PCI Backend Domain */ struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev, int domain, int bus,
@@ -67,14 +73,14 @@ void pciback_config_free_dyn_fields(struct pci_dev *dev);void pciback_config_reset_dev (struct pci_dev *dev);void pciback_config_free_dev (struct pci_dev *dev);int pciback_config_read (struct pci_dev *dev,int offset,int size, -u32 * ret_val); +u32 *ret_val);int pciback_config_write (struct pci_dev *dev,int offset,int size,u32 value);/* Handle requests for specific devices from the frontend */ typedef int (*publish_pci_dev_cb ) (struct pciback_device *pdev,unsigned int domain,unsigned int bus,unsigned int devfn,unsigned int devid); -typedef int (*publish_pci_root_cb ) (struct pciback_device * pdev, +typedef int (*publish_pci_root_cb ) (struct pciback_device *pdev,unsigned int domain,unsigned int bus);int pciback_add_pci_dev (struct pciback_device *pdev,struct pci_dev *dev,int devid,publish_pci_dev_cb publish_cb);
@@ -83,15 +89,17 @@ struct pci_dev *pciback_get_pci_dev(struct pciback_device *pdev, unsigned int domain, unsigned int bus, unsigned int devfn); -/** +/** * Add for domain0 PCIE-AER handling. Get guest domain/bus/devfn in pciback -* before sending aer request to pcifront, so that guest could identify +* before sending aer request to pcifront, so that guest could identify * device, coopearte with pciback to finish aer recovery job if device driver * has the capability */ -int pciback_get_pcifront_dev (struct pci_dev *pcidev,struct pciback_device *pdev, -unsigned int *domain,unsigned int *bus,unsigned int *devfn); +int pciback_get_pcifront_dev (struct pci_dev *pcidev, +struct pciback_device *pdev, +unsigned int *domain,unsigned int *bus, +unsigned int *devfn);int pciback_init_devices (struct pciback_device *pdev);int pciback_publish_pci_roots (struct pciback_device *pdev,publish_pci_root_cb cb);
@@ -106,17 +114,17 @@ void pciback_xenbus_unregister(void);#ifdef CONFIG_PCI_MSI int pciback_enable_msi (struct pciback_device *pdev, -struct pci_dev *dev,struct xen_pci_op *op); +struct pci_dev *dev,struct xen_pci_op *op);int pciback_disable_msi (struct pciback_device *pdev, -struct pci_dev *dev,struct xen_pci_op *op); +struct pci_dev *dev,struct xen_pci_op *op);int pciback_enable_msix (struct pciback_device *pdev, -struct pci_dev *dev,struct xen_pci_op *op); +struct pci_dev *dev,struct xen_pci_op *op);int pciback_disable_msix (struct pciback_device *pdev, -struct pci_dev *dev,struct xen_pci_op *op); +struct pci_dev *dev,struct xen_pci_op *op);#endif extern int verbose_request;
drivers/xen/pciback/pciback_ops.c +35 -39
124 lines not on this page · raw message
drivers/xen/pciback/slot.c +13 -9
@@ -65,7 +65,8 @@ int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev,for (slot =0 ; slot <PCI_SLOT_MAX ; slot++) {if (slot_dev->slots[bus][slot] ==NULL ) {printk (KERN_INFO -"pciback: slot: %s: assign to virtual slot %d, bus %d\n" , +"pciback: slot: %s: assign to virtual " +"slot %d, bus %d\n" ,pci_name (dev), slot, bus); slot_dev->slots[bus][slot] = dev; goto unlock;
@@ -76,14 +77,14 @@ int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev,xenbus_dev_fatal (pdev->xdev, err,"No more space on root virtual PCI bus" ); - unlock: +unlock:spin_unlock_irqrestore (&slot_dev->lock, flags);/* Publish this device. */ -if (!err) +if (!err) err =publish_cb (pdev,0 ,0 ,PCI_DEVFN (slot,0 ), devid); - out: +out:return err; }
@@ -105,7 +106,7 @@ void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev) } } - out: +out:spin_unlock_irqrestore (&slot_dev->lock, flags);if (found_dev)
@@ -156,8 +157,10 @@ void pciback_release_devices(struct pciback_device *pdev) pdev->pci_dev_data =NULL ; } -int pciback_get_pcifront_dev (struct pci_dev *pcidev,struct pciback_device *pdev, -unsigned int *domain,unsigned int *bus,unsigned int *devfn) +int pciback_get_pcifront_dev (struct pci_dev *pcidev, +struct pciback_device *pdev, +unsigned int *domain,unsigned int *bus, +unsigned int *devfn) {int slot, busnr;struct slot_dev_data *slot_dev = pdev->pci_dev_data;
@@ -172,11 +175,12 @@ int pciback_get_pcifront_dev(struct pci_dev *pcidev, struct pciback_device *pdev dev = slot_dev->slots[busnr][slot];if (dev && dev->bus->number == pcidev->bus->number && dev->devfn == pcidev->devfn - &&pci_domain_nr (dev->bus) ==pci_domain_nr (pcidev->bus)) { + &&pci_domain_nr (dev->bus) == +pci_domain_nr (pcidev->bus)) { found =1 ; *domain =0 ; *bus = busnr; - *devfn =PCI_DEVFN (slot,0 ); + *devfn =PCI_DEVFN (slot,0 ); goto out; } }
drivers/xen/pciback/vpci.c +15 -13
@@ -125,14 +125,14 @@ int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev,xenbus_dev_fatal (pdev->xdev, err,"No more space on root virtual PCI bus" ); - unlock: +unlock:spin_unlock_irqrestore (&vpci_dev->lock, flags);/* Publish this device. */ -if (!err) +if (!err) err =publish_cb (pdev,0 ,0 ,PCI_DEVFN (slot, func), devid); - out: +out:return err; }
@@ -158,7 +158,7 @@ void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev) } } - out: +out:spin_unlock_irqrestore (&vpci_dev->lock, flags);if (found_dev)
@@ -176,9 +176,8 @@ int pciback_init_devices(struct pciback_device *pdev)spin_lock_init (&vpci_dev->lock); -for (slot =0 ; slot <PCI_SLOT_MAX ; slot++) { +for (slot =0 ; slot <PCI_SLOT_MAX ; slot++)INIT_LIST_HEAD (&vpci_dev->dev_list[slot]); - } pdev->pci_dev_data = vpci_dev;
@@ -211,8 +210,10 @@ void pciback_release_devices(struct pciback_device *pdev) pdev->pci_dev_data =NULL ; } -int pciback_get_pcifront_dev (struct pci_dev *pcidev,struct pciback_device *pdev, -unsigned int *domain,unsigned int *bus,unsigned int *devfn) +int pciback_get_pcifront_dev (struct pci_dev *pcidev, +struct pciback_device *pdev, +unsigned int *domain,unsigned int *bus, +unsigned int *devfn) {struct pci_dev_entry *entry;struct pci_dev *dev =NULL ;
@@ -227,15 +228,16 @@ int pciback_get_pcifront_dev(struct pci_dev *pcidev, struct pciback_device *pdev list) { dev = entry->dev;if (dev && dev->bus->number == pcidev->bus->number - &&pci_domain_nr (dev->bus) ==pci_domain_nr (pcidev->bus) - && dev->devfn == pcidev->devfn) - { + &&pci_domain_nr (dev->bus) == +pci_domain_nr (pcidev->bus) + && dev->devfn == pcidev->devfn) { found =1 ; *domain =0 ; *bus =0 ; - *devfn =PCI_DEVFN (slot,PCI_FUNC (pcidev->devfn)); + *devfn =PCI_DEVFN (slot, +PCI_FUNC (pcidev->devfn)); } - } + } }spin_unlock_irqrestore (&vpci_dev->lock, flags);return found;
drivers/xen/pciback/xenbus.c +21 -21
146 lines not on this page · raw message
Signature · 1 line
1.6.2.5