aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Derrick <jonathan.derrick@intel.com>2016-09-02 13:53:05 -0400
committerBjorn Helgaas <bhelgaas@google.com>2016-09-19 14:14:05 -0400
commitb31822277abcd7c83d1c1c0af876da9ccdf3b7d6 (patch)
treea19469ef1e3b01f6fc209d9a921b930820d56bd9
parent53db86adc2c9b3ce0454bece4487e8eca96e2614 (diff)
x86/PCI: VMD: Eliminate index member from IRQ list
Use math to discover the IRQ list index number relative to the IRQ list head. Signed-off-by: Jon Derrick <jonathan.derrick@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Keith Busch <keith.busch@intel.com>
-rw-r--r--arch/x86/pci/vmd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
index 61a97ff36514..e785907acb79 100644
--- a/arch/x86/pci/vmd.c
+++ b/arch/x86/pci/vmd.c
@@ -56,13 +56,11 @@ struct vmd_irq {
56/** 56/**
57 * struct vmd_irq_list - list of driver requested IRQs mapping to a VMD vector 57 * struct vmd_irq_list - list of driver requested IRQs mapping to a VMD vector
58 * @irq_list: the list of irq's the VMD one demuxes to. 58 * @irq_list: the list of irq's the VMD one demuxes to.
59 * @index: index into the VMD MSI-X table; used for message routing.
60 * @count: number of child IRQs assigned to this vector; used to track 59 * @count: number of child IRQs assigned to this vector; used to track
61 * sharing. 60 * sharing.
62 */ 61 */
63struct vmd_irq_list { 62struct vmd_irq_list {
64 struct list_head irq_list; 63 struct list_head irq_list;
65 unsigned int index;
66 unsigned int count; 64 unsigned int count;
67}; 65};
68 66
@@ -91,6 +89,12 @@ static inline struct vmd_dev *vmd_from_bus(struct pci_bus *bus)
91 return container_of(bus->sysdata, struct vmd_dev, sysdata); 89 return container_of(bus->sysdata, struct vmd_dev, sysdata);
92} 90}
93 91
92static inline unsigned int index_from_irqs(struct vmd_dev *vmd,
93 struct vmd_irq_list *irqs)
94{
95 return irqs - vmd->irqs;
96}
97
94/* 98/*
95 * Drivers managing a device in a VMD domain allocate their own IRQs as before, 99 * Drivers managing a device in a VMD domain allocate their own IRQs as before,
96 * but the MSI entry for the hardware it's driving will be programmed with a 100 * but the MSI entry for the hardware it's driving will be programmed with a
@@ -103,9 +107,11 @@ static void vmd_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
103{ 107{
104 struct vmd_irq *vmdirq = data->chip_data; 108 struct vmd_irq *vmdirq = data->chip_data;
105 struct vmd_irq_list *irq = vmdirq->irq; 109 struct vmd_irq_list *irq = vmdirq->irq;
110 struct vmd_dev *vmd = irq_data_get_irq_handler_data(data);
106 111
107 msg->address_hi = MSI_ADDR_BASE_HI; 112 msg->address_hi = MSI_ADDR_BASE_HI;
108 msg->address_lo = MSI_ADDR_BASE_LO | MSI_ADDR_DEST_ID(irq->index); 113 msg->address_lo = MSI_ADDR_BASE_LO |
114 MSI_ADDR_DEST_ID(index_from_irqs(vmd, irq));
109 msg->data = 0; 115 msg->data = 0;
110} 116}
111 117
@@ -190,6 +196,7 @@ static int vmd_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
190 struct msi_desc *desc = arg->desc; 196 struct msi_desc *desc = arg->desc;
191 struct vmd_dev *vmd = vmd_from_bus(msi_desc_to_pci_dev(desc)->bus); 197 struct vmd_dev *vmd = vmd_from_bus(msi_desc_to_pci_dev(desc)->bus);
192 struct vmd_irq *vmdirq = kzalloc(sizeof(*vmdirq), GFP_KERNEL); 198 struct vmd_irq *vmdirq = kzalloc(sizeof(*vmdirq), GFP_KERNEL);
199 unsigned int index, vector;
193 200
194 if (!vmdirq) 201 if (!vmdirq)
195 return -ENOMEM; 202 return -ENOMEM;
@@ -197,10 +204,10 @@ static int vmd_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
197 INIT_LIST_HEAD(&vmdirq->node); 204 INIT_LIST_HEAD(&vmdirq->node);
198 vmdirq->irq = vmd_next_irq(vmd, desc); 205 vmdirq->irq = vmd_next_irq(vmd, desc);
199 vmdirq->virq = virq; 206 vmdirq->virq = virq;
207 index = index_from_irqs(vmd, vmdirq->irq);
208 vector = pci_irq_vector(vmd->dev, index);
200 209
201 irq_domain_set_info(domain, virq, 210 irq_domain_set_info(domain, virq, vector, info->chip, vmdirq,
202 pci_irq_vector(vmd->dev, vmdirq->irq->index),
203 info->chip, vmdirq,
204 handle_untracked_irq, vmd, NULL); 211 handle_untracked_irq, vmd, NULL);
205 return 0; 212 return 0;
206} 213}
@@ -681,7 +688,6 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
681 688
682 for (i = 0; i < vmd->msix_count; i++) { 689 for (i = 0; i < vmd->msix_count; i++) {
683 INIT_LIST_HEAD(&vmd->irqs[i].irq_list); 690 INIT_LIST_HEAD(&vmd->irqs[i].irq_list);
684 vmd->irqs[i].index = i;
685 err = devm_request_irq(&dev->dev, pci_irq_vector(dev, i), 691 err = devm_request_irq(&dev->dev, pci_irq_vector(dev, i),
686 vmd_irq, 0, "vmd", &vmd->irqs[i]); 692 vmd_irq, 0, "vmd", &vmd->irqs[i]);
687 if (err) 693 if (err)