Skip to content

Commit 969864e

Browse files
RajuRangojuwsakernel
authored andcommitted
i2c: amd-mp2: use msix/msi if the hardware supports
Use msix or msi interrupts if the hardware supports it. Else, fallback to legacy interrupts. Co-developed-by: Basavaraj Natikar <basavaraj.natikar@amd.com> Signed-off-by: Basavaraj Natikar <basavaraj.natikar@amd.com> Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com> Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 30a0b95 commit 969864e

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

drivers/i2c/busses/i2c-amd-mp2-pci.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static void amd_mp2_clear_reg(struct amd_mp2_dev *privdata)
288288
static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
289289
struct pci_dev *pci_dev)
290290
{
291-
int rc;
291+
int irq_flag = 0, rc;
292292

293293
pci_set_drvdata(pci_dev, privdata);
294294

@@ -311,17 +311,29 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
311311
if (rc)
312312
goto err_dma_mask;
313313

314-
/* Set up intx irq */
314+
/* request and enable interrupt */
315315
writel(0, privdata->mmio + AMD_P2C_MSG_INTEN);
316-
pci_intx(pci_dev, 1);
317-
rc = devm_request_irq(&pci_dev->dev, pci_dev->irq, amd_mp2_irq_isr,
318-
IRQF_SHARED, dev_name(&pci_dev->dev), privdata);
319-
if (rc)
320-
pci_err(pci_dev, "Failure requesting irq %i: %d\n",
321-
pci_dev->irq, rc);
316+
rc = pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
317+
if (rc < 0) {
318+
dev_err(&pci_dev->dev, "Failed to allocate single IRQ err=%d\n", rc);
319+
goto err_dma_mask;
320+
}
321+
322+
privdata->dev_irq = pci_irq_vector(pci_dev, 0);
323+
if (!pci_dev->msix_enabled && !pci_dev->msi_enabled)
324+
irq_flag = IRQF_SHARED;
325+
326+
rc = devm_request_irq(&pci_dev->dev, privdata->dev_irq,
327+
amd_mp2_irq_isr, irq_flag, dev_name(&pci_dev->dev), privdata);
328+
if (rc) {
329+
pci_err(pci_dev, "Failure requesting irq %i: %d\n", privdata->dev_irq, rc);
330+
goto free_irq_vectors;
331+
}
322332

323333
return rc;
324334

335+
free_irq_vectors:
336+
free_irq(privdata->dev_irq, privdata);
325337
err_dma_mask:
326338
pci_clear_master(pci_dev);
327339
err_pci_enable:
@@ -364,7 +376,7 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev)
364376
pm_runtime_forbid(&pci_dev->dev);
365377
pm_runtime_get_noresume(&pci_dev->dev);
366378

367-
pci_intx(pci_dev, 0);
379+
free_irq(privdata->dev_irq, privdata);
368380
pci_clear_master(pci_dev);
369381

370382
amd_mp2_clear_reg(privdata);

drivers/i2c/busses/i2c-amd-mp2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct amd_mp2_dev {
183183
struct mutex c2p_lock;
184184
u8 c2p_lock_busid;
185185
unsigned int probed;
186+
int dev_irq;
186187
};
187188

188189
/* PCIe communication driver */

0 commit comments

Comments
 (0)