1 From 8b5d421b2bfa6800d182f74a60afa48cf305fb86 Mon Sep 17 00:00:00 2001
2 From: Jan Kiszka <jan.kiszka@siemens.com>
3 Date: Tue, 23 May 2017 17:41:00 +0200
4 Subject: [PATCH] ivshmem-net: Switch to pci_alloc_irq_vectors
6 Required by 4.12, and it also simplifies our code. Needs to be folded
7 into the initial patch eventually.
9 Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 (cherry picked from commit ea6e78c89582711f15a2711f0a35ac3a61d9d074)
12 drivers/net/ivshmem-net.c | 66 ++++++++++++++++++++---------------------------
13 1 file changed, 28 insertions(+), 38 deletions(-)
15 --- a/drivers/net/ivshmem-net.c
16 +++ b/drivers/net/ivshmem-net.c
17 @@ -114,8 +114,6 @@ struct ivshm_net {
21 - struct msix_entry msix;
25 static void *ivshm_net_desc_data(struct ivshm_net *in,
26 @@ -793,22 +791,21 @@ static int ivshm_net_probe(struct pci_de
27 struct ivshmem_regs __iomem *regs;
28 resource_size_t shmaddr;
29 resource_size_t shmlen;
37 - err = pcim_enable_device(pdev);
39 - dev_err(&pdev->dev, "pci_enable_device: %d\n", err);
41 + ret = pcim_enable_device(pdev);
43 + dev_err(&pdev->dev, "pci_enable_device: %d\n", ret);
47 - err = pcim_iomap_regions(pdev, BIT(0), DRV_NAME);
49 - dev_err(&pdev->dev, "pcim_iomap_regions: %d\n", err);
51 + ret = pcim_iomap_regions(pdev, BIT(0), DRV_NAME);
53 + dev_err(&pdev->dev, "pcim_iomap_regions: %d\n", ret);
57 regs = pcim_iomap_table(pdev)[0];
58 @@ -869,8 +866,8 @@ static int ivshm_net_probe(struct pci_de
59 spin_lock_init(&in->tx_free_lock);
60 spin_lock_init(&in->tx_clean_lock);
62 - err = ivshm_net_calc_qsize(ndev);
64 + ret = ivshm_net_calc_qsize(ndev);
68 in->state_wq = alloc_ordered_workqueue(device_name, 0);
69 @@ -889,25 +886,21 @@ static int ivshm_net_probe(struct pci_de
70 netif_carrier_off(ndev);
71 netif_napi_add(ndev, &in->napi, ivshm_net_poll, NAPI_POLL_WEIGHT);
73 - err = register_netdev(ndev);
75 + ret = register_netdev(ndev);
79 - err = pci_enable_msix(pdev, &in->msix, 1);
81 - interrupt = in->msix.vector;
82 - in->using_msix = true;
84 - interrupt = pdev->irq;
85 - in->using_msix = false;
88 - err = request_irq(interrupt, ivshm_net_int, 0, device_name, ndev);
91 + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSIX);
95 + ret = request_irq(pci_irq_vector(pdev, 0), ivshm_net_int, 0,
98 + goto err_request_irq;
100 pci_set_master(pdev);
101 - if (!in->using_msix)
102 + if (!pdev->msix_enabled)
103 writel(IVSHMEM_INTX_ENABLE, &in->ivshm_regs->intxctrl);
105 writel(IVSHM_NET_STATE_RESET, &in->ivshm_regs->lstate);
106 @@ -915,16 +908,16 @@ static int ivshm_net_probe(struct pci_de
111 - if (in->using_msix)
112 - pci_disable_msix(pdev);
114 + pci_free_irq_vectors(pdev);
116 unregister_netdev(ndev);
118 destroy_workqueue(in->state_wq);
126 static void ivshm_net_remove(struct pci_dev *pdev)
127 @@ -934,13 +927,10 @@ static void ivshm_net_remove(struct pci_
129 writel(IVSHM_NET_STATE_RESET, &in->ivshm_regs->lstate);
131 - if (in->using_msix) {
132 - free_irq(in->msix.vector, ndev);
133 - pci_disable_msix(pdev);
135 + if (!pdev->msix_enabled)
136 writel(0, &in->ivshm_regs->intxctrl);
137 - free_irq(pdev->irq, ndev);
139 + free_irq(pci_irq_vector(pdev, 0), ndev);
140 + pci_free_irq_vectors(pdev);
142 unregister_netdev(ndev);
143 cancel_work_sync(&in->state_work);