lkml.org 
[lkml]   [2018]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/3] mei: Migrate to pci_alloc_irq_vectors API
From
Date
Update the driver to the pci_alloc_irq_vectors API, this allows to get
rid of legacy calls like pci_enable_msi(). Another benefit is that
no driver change would be needed in case the hardware starts
supporting MSI-X.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/misc/mei/pci-me.c | 25 +++++++++++--------------
drivers/misc/mei/pci-txe.c | 30 ++++++++++++++----------------
2 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 55ba1c41..a60376f0 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -149,7 +149,6 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
const struct mei_cfg *cfg;
struct mei_device *dev;
struct mei_me_hw *hw;
- unsigned int irqflags;
int err;

cfg = mei_me_get_cfg(ent->driver_data);
@@ -196,18 +195,16 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hw = to_me_hw(dev);
hw->mem_addr = pcim_iomap_table(pdev)[0];

- pci_enable_msi(pdev);
-
- /* request and enable interrupt */
- irqflags = pci_dev_msi_enabled(pdev) ? IRQF_ONESHOT : IRQF_SHARED;
+ err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+ if (err < 0)
+ goto end;

- err = request_threaded_irq(pdev->irq,
- mei_me_irq_quick_handler,
- mei_me_irq_thread_handler,
- irqflags, KBUILD_MODNAME, dev);
+ /* request and enable interrupt */
+ err = pci_request_irq(pdev, 0, mei_me_irq_quick_handler,
+ mei_me_irq_thread_handler, dev, KBUILD_MODNAME);
if (err) {
- dev_err(&pdev->dev, "request_threaded_irq failure. irq = %d\n",
- pdev->irq);
+ pci_err(pdev, "pci_request_irq failure. irq = %d\n",
+ pci_irq_vector(pdev, 0));
goto end;
}

@@ -258,7 +255,7 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
release_irq:
mei_cancel_work(dev);
mei_disable_interrupts(dev);
- free_irq(pdev->irq, dev);
+ pci_free_irq(pdev, 0, dev);
end:
dev_err(&pdev->dev, "initialization failed.\n");
return err;
@@ -287,7 +284,7 @@ static void mei_me_shutdown(struct pci_dev *pdev)
mei_me_unset_pm_domain(dev);

mei_disable_interrupts(dev);
- free_irq(pdev->irq, dev);
+ pci_free_irq(pdev, 0, dev);
}

/**
@@ -316,7 +313,7 @@ static void mei_me_remove(struct pci_dev *pdev)

mei_disable_interrupts(dev);

- free_irq(pdev->irq, dev);
+ pci_free_irq(pdev, 0, dev);

mei_deregister(dev);
}
diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
index b8a49581..3ea2b8f6 100644
--- a/drivers/misc/mei/pci-txe.c
+++ b/drivers/misc/mei/pci-txe.c
@@ -64,6 +64,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct mei_device *dev;
struct mei_txe_hw *hw;
+ irq_handler_t qh = NULL;
const int mask = BIT(SEC_BAR) | BIT(BRIDGE_BAR);
int err;

@@ -100,25 +101,22 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hw = to_txe_hw(dev);
hw->mem_addr = pcim_iomap_table(pdev);

- pci_enable_msi(pdev);
+ err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+ if (err < 0)
+ goto end;

/* clear spurious interrupts */
mei_clear_interrupts(dev);

+ if (!pci_dev_msi_enabled(pdev))
+ qh = mei_txe_irq_quick_handler;
+
/* request and enable interrupt */
- if (pci_dev_msi_enabled(pdev))
- err = request_threaded_irq(pdev->irq,
- NULL,
- mei_txe_irq_thread_handler,
- IRQF_ONESHOT, KBUILD_MODNAME, dev);
- else
- err = request_threaded_irq(pdev->irq,
- mei_txe_irq_quick_handler,
- mei_txe_irq_thread_handler,
- IRQF_SHARED, KBUILD_MODNAME, dev);
+ err = pci_request_irq(pdev, 0, qh, mei_txe_irq_thread_handler,
+ dev, KBUILD_MODNAME);
if (err) {
- dev_err(&pdev->dev, "mei: request_threaded_irq failure. irq = %d\n",
- pdev->irq);
+ pci_err(pdev, "mei: pci_request_irq failure. irq = %d\n",
+ pci_irq_vector(pdev, 0));
goto end;
}

@@ -162,7 +160,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
release_irq:
mei_cancel_work(dev);
mei_disable_interrupts(dev);
- free_irq(pdev->irq, dev);
+ pci_free_irq(pdev, 0, dev);
end:
dev_err(&pdev->dev, "initialization failed.\n");
return err;
@@ -191,7 +189,7 @@ static void mei_txe_shutdown(struct pci_dev *pdev)
mei_txe_unset_pm_domain(dev);

mei_disable_interrupts(dev);
- free_irq(pdev->irq, dev);
+ pci_free_irq(pdev, 0, dev);
}

/**
@@ -219,7 +217,7 @@ static void mei_txe_remove(struct pci_dev *pdev)
mei_txe_unset_pm_domain(dev);

mei_disable_interrupts(dev);
- free_irq(pdev->irq, dev);
+ pci_free_irq(pdev, 0, dev);

mei_deregister(dev);
}
--
2.18.0

\
 
 \ /
  Last update: 2018-08-03 23:43    [W:0.049 / U:4.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site