diff options
| -rw-r--r-- | drivers/pci/host/pci-hyperv.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index a8deeca984cf..6fa40f111962 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c | |||
| @@ -200,11 +200,11 @@ struct tran_int_desc { | |||
| 200 | */ | 200 | */ |
| 201 | 201 | ||
| 202 | struct pci_message { | 202 | struct pci_message { |
| 203 | u32 message_type; | 203 | u32 type; |
| 204 | } __packed; | 204 | } __packed; |
| 205 | 205 | ||
| 206 | struct pci_child_message { | 206 | struct pci_child_message { |
| 207 | u32 message_type; | 207 | struct pci_message message_type; |
| 208 | union win_slot_encoding wslot; | 208 | union win_slot_encoding wslot; |
| 209 | } __packed; | 209 | } __packed; |
| 210 | 210 | ||
| @@ -222,7 +222,8 @@ struct pci_packet { | |||
| 222 | void (*completion_func)(void *context, struct pci_response *resp, | 222 | void (*completion_func)(void *context, struct pci_response *resp, |
| 223 | int resp_packet_size); | 223 | int resp_packet_size); |
| 224 | void *compl_ctxt; | 224 | void *compl_ctxt; |
| 225 | struct pci_message message; | 225 | |
| 226 | struct pci_message message[0]; | ||
| 226 | }; | 227 | }; |
| 227 | 228 | ||
| 228 | /* | 229 | /* |
| @@ -314,7 +315,7 @@ struct pci_dev_incoming { | |||
| 314 | } __packed; | 315 | } __packed; |
| 315 | 316 | ||
| 316 | struct pci_eject_response { | 317 | struct pci_eject_response { |
| 317 | u32 message_type; | 318 | struct pci_message message_type; |
| 318 | union win_slot_encoding wslot; | 319 | union win_slot_encoding wslot; |
| 319 | u32 status; | 320 | u32 status; |
| 320 | } __packed; | 321 | } __packed; |
| @@ -694,13 +695,12 @@ static void hv_int_desc_free(struct hv_pci_dev *hpdev, | |||
| 694 | struct pci_delete_interrupt *int_pkt; | 695 | struct pci_delete_interrupt *int_pkt; |
| 695 | struct { | 696 | struct { |
| 696 | struct pci_packet pkt; | 697 | struct pci_packet pkt; |
| 697 | u8 buffer[sizeof(struct pci_delete_interrupt) - | 698 | u8 buffer[sizeof(struct pci_delete_interrupt)]; |
| 698 | sizeof(struct pci_message)]; | ||
| 699 | } ctxt; | 699 | } ctxt; |
| 700 | 700 | ||
| 701 | memset(&ctxt, 0, sizeof(ctxt)); | 701 | memset(&ctxt, 0, sizeof(ctxt)); |
| 702 | int_pkt = (struct pci_delete_interrupt *)&ctxt.pkt.message; | 702 | int_pkt = (struct pci_delete_interrupt *)&ctxt.pkt.message; |
| 703 | int_pkt->message_type.message_type = | 703 | int_pkt->message_type.type = |
| 704 | PCI_DELETE_INTERRUPT_MESSAGE; | 704 | PCI_DELETE_INTERRUPT_MESSAGE; |
| 705 | int_pkt->wslot.slot = hpdev->desc.win_slot.slot; | 705 | int_pkt->wslot.slot = hpdev->desc.win_slot.slot; |
| 706 | int_pkt->int_desc = *int_desc; | 706 | int_pkt->int_desc = *int_desc; |
| @@ -847,8 +847,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) | |||
| 847 | struct cpumask *affinity; | 847 | struct cpumask *affinity; |
| 848 | struct { | 848 | struct { |
| 849 | struct pci_packet pkt; | 849 | struct pci_packet pkt; |
| 850 | u8 buffer[sizeof(struct pci_create_interrupt) - | 850 | u8 buffer[sizeof(struct pci_create_interrupt)]; |
| 851 | sizeof(struct pci_message)]; | ||
| 852 | } ctxt; | 851 | } ctxt; |
| 853 | int cpu; | 852 | int cpu; |
| 854 | int ret; | 853 | int ret; |
| @@ -876,7 +875,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) | |||
| 876 | ctxt.pkt.completion_func = hv_pci_compose_compl; | 875 | ctxt.pkt.completion_func = hv_pci_compose_compl; |
| 877 | ctxt.pkt.compl_ctxt = ∁ | 876 | ctxt.pkt.compl_ctxt = ∁ |
| 878 | int_pkt = (struct pci_create_interrupt *)&ctxt.pkt.message; | 877 | int_pkt = (struct pci_create_interrupt *)&ctxt.pkt.message; |
| 879 | int_pkt->message_type.message_type = PCI_CREATE_INTERRUPT_MESSAGE; | 878 | int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE; |
| 880 | int_pkt->wslot.slot = hpdev->desc.win_slot.slot; | 879 | int_pkt->wslot.slot = hpdev->desc.win_slot.slot; |
| 881 | int_pkt->int_desc.vector = cfg->vector; | 880 | int_pkt->int_desc.vector = cfg->vector; |
| 882 | int_pkt->int_desc.vector_count = 1; | 881 | int_pkt->int_desc.vector_count = 1; |
| @@ -1289,7 +1288,7 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, | |||
| 1289 | pkt.init_packet.compl_ctxt = &comp_pkt; | 1288 | pkt.init_packet.compl_ctxt = &comp_pkt; |
| 1290 | pkt.init_packet.completion_func = q_resource_requirements; | 1289 | pkt.init_packet.completion_func = q_resource_requirements; |
| 1291 | res_req = (struct pci_child_message *)&pkt.init_packet.message; | 1290 | res_req = (struct pci_child_message *)&pkt.init_packet.message; |
| 1292 | res_req->message_type = PCI_QUERY_RESOURCE_REQUIREMENTS; | 1291 | res_req->message_type.type = PCI_QUERY_RESOURCE_REQUIREMENTS; |
| 1293 | res_req->wslot.slot = desc->win_slot.slot; | 1292 | res_req->wslot.slot = desc->win_slot.slot; |
| 1294 | 1293 | ||
| 1295 | ret = vmbus_sendpacket(hbus->hdev->channel, res_req, | 1294 | ret = vmbus_sendpacket(hbus->hdev->channel, res_req, |
| @@ -1557,8 +1556,7 @@ static void hv_eject_device_work(struct work_struct *work) | |||
| 1557 | int wslot; | 1556 | int wslot; |
| 1558 | struct { | 1557 | struct { |
| 1559 | struct pci_packet pkt; | 1558 | struct pci_packet pkt; |
| 1560 | u8 buffer[sizeof(struct pci_eject_response) - | 1559 | u8 buffer[sizeof(struct pci_eject_response)]; |
| 1561 | sizeof(struct pci_message)]; | ||
| 1562 | } ctxt; | 1560 | } ctxt; |
| 1563 | 1561 | ||
| 1564 | hpdev = container_of(work, struct hv_pci_dev, wrk); | 1562 | hpdev = container_of(work, struct hv_pci_dev, wrk); |
| @@ -1584,7 +1582,7 @@ static void hv_eject_device_work(struct work_struct *work) | |||
| 1584 | 1582 | ||
| 1585 | memset(&ctxt, 0, sizeof(ctxt)); | 1583 | memset(&ctxt, 0, sizeof(ctxt)); |
| 1586 | ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; | 1584 | ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; |
| 1587 | ejct_pkt->message_type = PCI_EJECTION_COMPLETE; | 1585 | ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE; |
| 1588 | ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; | 1586 | ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; |
| 1589 | vmbus_sendpacket(hpdev->hbus->hdev->channel, ejct_pkt, | 1587 | vmbus_sendpacket(hpdev->hbus->hdev->channel, ejct_pkt, |
| 1590 | sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt, | 1588 | sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt, |
| @@ -1687,7 +1685,7 @@ static void hv_pci_onchannelcallback(void *context) | |||
| 1687 | case VM_PKT_DATA_INBAND: | 1685 | case VM_PKT_DATA_INBAND: |
| 1688 | 1686 | ||
| 1689 | new_message = (struct pci_incoming_message *)buffer; | 1687 | new_message = (struct pci_incoming_message *)buffer; |
| 1690 | switch (new_message->message_type.message_type) { | 1688 | switch (new_message->message_type.type) { |
| 1691 | case PCI_BUS_RELATIONS: | 1689 | case PCI_BUS_RELATIONS: |
| 1692 | 1690 | ||
| 1693 | bus_rel = (struct pci_bus_relations *)buffer; | 1691 | bus_rel = (struct pci_bus_relations *)buffer; |
| @@ -1718,7 +1716,7 @@ static void hv_pci_onchannelcallback(void *context) | |||
| 1718 | default: | 1716 | default: |
| 1719 | dev_warn(&hbus->hdev->device, | 1717 | dev_warn(&hbus->hdev->device, |
| 1720 | "Unimplemented protocol message %x\n", | 1718 | "Unimplemented protocol message %x\n", |
| 1721 | new_message->message_type.message_type); | 1719 | new_message->message_type.type); |
| 1722 | break; | 1720 | break; |
| 1723 | } | 1721 | } |
| 1724 | break; | 1722 | break; |
| @@ -1771,7 +1769,7 @@ static int hv_pci_protocol_negotiation(struct hv_device *hdev) | |||
| 1771 | pkt->completion_func = hv_pci_generic_compl; | 1769 | pkt->completion_func = hv_pci_generic_compl; |
| 1772 | pkt->compl_ctxt = &comp_pkt; | 1770 | pkt->compl_ctxt = &comp_pkt; |
| 1773 | version_req = (struct pci_version_request *)&pkt->message; | 1771 | version_req = (struct pci_version_request *)&pkt->message; |
| 1774 | version_req->message_type.message_type = PCI_QUERY_PROTOCOL_VERSION; | 1772 | version_req->message_type.type = PCI_QUERY_PROTOCOL_VERSION; |
| 1775 | version_req->protocol_version = PCI_PROTOCOL_VERSION_CURRENT; | 1773 | version_req->protocol_version = PCI_PROTOCOL_VERSION_CURRENT; |
| 1776 | 1774 | ||
| 1777 | ret = vmbus_sendpacket(hdev->channel, version_req, | 1775 | ret = vmbus_sendpacket(hdev->channel, version_req, |
| @@ -1972,7 +1970,7 @@ static int hv_pci_enter_d0(struct hv_device *hdev) | |||
| 1972 | pkt->completion_func = hv_pci_generic_compl; | 1970 | pkt->completion_func = hv_pci_generic_compl; |
| 1973 | pkt->compl_ctxt = &comp_pkt; | 1971 | pkt->compl_ctxt = &comp_pkt; |
| 1974 | d0_entry = (struct pci_bus_d0_entry *)&pkt->message; | 1972 | d0_entry = (struct pci_bus_d0_entry *)&pkt->message; |
| 1975 | d0_entry->message_type.message_type = PCI_BUS_D0ENTRY; | 1973 | d0_entry->message_type.type = PCI_BUS_D0ENTRY; |
| 1976 | d0_entry->mmio_base = hbus->mem_config->start; | 1974 | d0_entry->mmio_base = hbus->mem_config->start; |
| 1977 | 1975 | ||
| 1978 | ret = vmbus_sendpacket(hdev->channel, d0_entry, sizeof(*d0_entry), | 1976 | ret = vmbus_sendpacket(hdev->channel, d0_entry, sizeof(*d0_entry), |
| @@ -2018,7 +2016,7 @@ static int hv_pci_query_relations(struct hv_device *hdev) | |||
| 2018 | return -ENOTEMPTY; | 2016 | return -ENOTEMPTY; |
| 2019 | 2017 | ||
| 2020 | memset(&message, 0, sizeof(message)); | 2018 | memset(&message, 0, sizeof(message)); |
| 2021 | message.message_type = PCI_QUERY_BUS_RELATIONS; | 2019 | message.type = PCI_QUERY_BUS_RELATIONS; |
| 2022 | 2020 | ||
| 2023 | ret = vmbus_sendpacket(hdev->channel, &message, sizeof(message), | 2021 | ret = vmbus_sendpacket(hdev->channel, &message, sizeof(message), |
| 2024 | 0, VM_PKT_DATA_INBAND, 0); | 2022 | 0, VM_PKT_DATA_INBAND, 0); |
| @@ -2071,8 +2069,8 @@ static int hv_send_resources_allocated(struct hv_device *hdev) | |||
| 2071 | init_completion(&comp_pkt.host_event); | 2069 | init_completion(&comp_pkt.host_event); |
| 2072 | pkt->completion_func = hv_pci_generic_compl; | 2070 | pkt->completion_func = hv_pci_generic_compl; |
| 2073 | pkt->compl_ctxt = &comp_pkt; | 2071 | pkt->compl_ctxt = &comp_pkt; |
| 2074 | pkt->message.message_type = PCI_RESOURCES_ASSIGNED; | ||
| 2075 | res_assigned = (struct pci_resources_assigned *)&pkt->message; | 2072 | res_assigned = (struct pci_resources_assigned *)&pkt->message; |
| 2073 | res_assigned->message_type.type = PCI_RESOURCES_ASSIGNED; | ||
| 2076 | res_assigned->wslot.slot = hpdev->desc.win_slot.slot; | 2074 | res_assigned->wslot.slot = hpdev->desc.win_slot.slot; |
| 2077 | 2075 | ||
| 2078 | put_pcichild(hpdev, hv_pcidev_ref_by_slot); | 2076 | put_pcichild(hpdev, hv_pcidev_ref_by_slot); |
| @@ -2122,7 +2120,7 @@ static int hv_send_resources_released(struct hv_device *hdev) | |||
| 2122 | continue; | 2120 | continue; |
| 2123 | 2121 | ||
| 2124 | memset(&pkt, 0, sizeof(pkt)); | 2122 | memset(&pkt, 0, sizeof(pkt)); |
| 2125 | pkt.message_type = PCI_RESOURCES_RELEASED; | 2123 | pkt.message_type.type = PCI_RESOURCES_RELEASED; |
| 2126 | pkt.wslot.slot = hpdev->desc.win_slot.slot; | 2124 | pkt.wslot.slot = hpdev->desc.win_slot.slot; |
| 2127 | 2125 | ||
| 2128 | put_pcichild(hpdev, hv_pcidev_ref_by_slot); | 2126 | put_pcichild(hpdev, hv_pcidev_ref_by_slot); |
| @@ -2289,7 +2287,7 @@ static int hv_pci_remove(struct hv_device *hdev) | |||
| 2289 | init_completion(&comp_pkt.host_event); | 2287 | init_completion(&comp_pkt.host_event); |
| 2290 | pkt.teardown_packet.completion_func = hv_pci_generic_compl; | 2288 | pkt.teardown_packet.completion_func = hv_pci_generic_compl; |
| 2291 | pkt.teardown_packet.compl_ctxt = &comp_pkt; | 2289 | pkt.teardown_packet.compl_ctxt = &comp_pkt; |
| 2292 | pkt.teardown_packet.message.message_type = PCI_BUS_D0EXIT; | 2290 | pkt.teardown_packet.message[0].type = PCI_BUS_D0EXIT; |
| 2293 | 2291 | ||
| 2294 | ret = vmbus_sendpacket(hdev->channel, &pkt.teardown_packet.message, | 2292 | ret = vmbus_sendpacket(hdev->channel, &pkt.teardown_packet.message, |
| 2295 | sizeof(struct pci_message), | 2293 | sizeof(struct pci_message), |
