* [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports
@ 2022-10-25 18:11 Raju Rangoju
2022-10-28 3:58 ` Shyam Sundar S K
2022-11-01 12:33 ` Wolfram Sang
0 siblings, 2 replies; 4+ messages in thread
From: Raju Rangoju @ 2022-10-25 18:11 UTC (permalink / raw)
To: syniurge, shyam-sundar.s-k
Cc: linux-i2c, linux-kernel, rajesh1.kumar, Raju Rangoju,
Basavaraj Natikar
Use msix or msi interrupts if the hardware supports it. Else, fallback to
legacy interrupts.
Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
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>
---
drivers/i2c/busses/i2c-amd-mp2-pci.c | 30 +++++++++++++++++++---------
drivers/i2c/busses/i2c-amd-mp2.h | 1 +
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
index f57077a7448d..143165300949 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
@@ -288,7 +288,7 @@ static void amd_mp2_clear_reg(struct amd_mp2_dev *privdata)
static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
struct pci_dev *pci_dev)
{
- int rc;
+ int irq_flag = 0, rc;
pci_set_drvdata(pci_dev, privdata);
@@ -311,17 +311,29 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
if (rc)
goto err_dma_mask;
- /* Set up intx irq */
+ /* request and enable interrupt */
writel(0, privdata->mmio + AMD_P2C_MSG_INTEN);
- pci_intx(pci_dev, 1);
- rc = devm_request_irq(&pci_dev->dev, pci_dev->irq, amd_mp2_irq_isr,
- IRQF_SHARED, dev_name(&pci_dev->dev), privdata);
- if (rc)
- pci_err(pci_dev, "Failure requesting irq %i: %d\n",
- pci_dev->irq, rc);
+ rc = pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
+ if (rc < 0) {
+ dev_err(&pci_dev->dev, "Failed to allocate single IRQ err=%d\n", rc);
+ goto err_dma_mask;
+ }
+
+ privdata->dev_irq = pci_irq_vector(pci_dev, 0);
+ if (!pci_dev->msix_enabled && !pci_dev->msi_enabled)
+ irq_flag = IRQF_SHARED;
+
+ rc = devm_request_irq(&pci_dev->dev, privdata->dev_irq,
+ amd_mp2_irq_isr, irq_flag, dev_name(&pci_dev->dev), privdata);
+ if (rc) {
+ pci_err(pci_dev, "Failure requesting irq %i: %d\n", privdata->dev_irq, rc);
+ goto free_irq_vectors;
+ }
return rc;
+free_irq_vectors:
+ free_irq(privdata->dev_irq, privdata);
err_dma_mask:
pci_clear_master(pci_dev);
err_pci_enable:
@@ -364,7 +376,7 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev)
pm_runtime_forbid(&pci_dev->dev);
pm_runtime_get_noresume(&pci_dev->dev);
- pci_intx(pci_dev, 0);
+ free_irq(privdata->dev_irq, privdata);
pci_clear_master(pci_dev);
amd_mp2_clear_reg(privdata);
diff --git a/drivers/i2c/busses/i2c-amd-mp2.h b/drivers/i2c/busses/i2c-amd-mp2.h
index ddecd0c88656..018a42de8b1e 100644
--- a/drivers/i2c/busses/i2c-amd-mp2.h
+++ b/drivers/i2c/busses/i2c-amd-mp2.h
@@ -183,6 +183,7 @@ struct amd_mp2_dev {
struct mutex c2p_lock;
u8 c2p_lock_busid;
unsigned int probed;
+ int dev_irq;
};
/* PCIe communication driver */
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports
2022-10-25 18:11 [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports Raju Rangoju
@ 2022-10-28 3:58 ` Shyam Sundar S K
2022-11-01 12:33 ` Wolfram Sang
1 sibling, 0 replies; 4+ messages in thread
From: Shyam Sundar S K @ 2022-10-28 3:58 UTC (permalink / raw)
To: Raju Rangoju, syniurge
Cc: linux-i2c, linux-kernel, rajesh1.kumar, Basavaraj Natikar
On 10/25/2022 11:41 PM, Raju Rangoju wrote:
> Use msix or msi interrupts if the hardware supports it. Else, fallback to
> legacy interrupts.
>
> Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
> 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>
Looks good to me.
Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
> drivers/i2c/busses/i2c-amd-mp2-pci.c | 30 +++++++++++++++++++---------
> drivers/i2c/busses/i2c-amd-mp2.h | 1 +
> 2 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
> index f57077a7448d..143165300949 100644
> --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
> +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
> @@ -288,7 +288,7 @@ static void amd_mp2_clear_reg(struct amd_mp2_dev *privdata)
> static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
> struct pci_dev *pci_dev)
> {
> - int rc;
> + int irq_flag = 0, rc;
>
> pci_set_drvdata(pci_dev, privdata);
>
> @@ -311,17 +311,29 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
> if (rc)
> goto err_dma_mask;
>
> - /* Set up intx irq */
> + /* request and enable interrupt */
> writel(0, privdata->mmio + AMD_P2C_MSG_INTEN);
> - pci_intx(pci_dev, 1);
> - rc = devm_request_irq(&pci_dev->dev, pci_dev->irq, amd_mp2_irq_isr,
> - IRQF_SHARED, dev_name(&pci_dev->dev), privdata);
> - if (rc)
> - pci_err(pci_dev, "Failure requesting irq %i: %d\n",
> - pci_dev->irq, rc);
> + rc = pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
> + if (rc < 0) {
> + dev_err(&pci_dev->dev, "Failed to allocate single IRQ err=%d\n", rc);
> + goto err_dma_mask;
> + }
> +
> + privdata->dev_irq = pci_irq_vector(pci_dev, 0);
> + if (!pci_dev->msix_enabled && !pci_dev->msi_enabled)
> + irq_flag = IRQF_SHARED;
> +
> + rc = devm_request_irq(&pci_dev->dev, privdata->dev_irq,
> + amd_mp2_irq_isr, irq_flag, dev_name(&pci_dev->dev), privdata);
> + if (rc) {
> + pci_err(pci_dev, "Failure requesting irq %i: %d\n", privdata->dev_irq, rc);
> + goto free_irq_vectors;
> + }
>
> return rc;
>
> +free_irq_vectors:
> + free_irq(privdata->dev_irq, privdata);
> err_dma_mask:
> pci_clear_master(pci_dev);
> err_pci_enable:
> @@ -364,7 +376,7 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev)
> pm_runtime_forbid(&pci_dev->dev);
> pm_runtime_get_noresume(&pci_dev->dev);
>
> - pci_intx(pci_dev, 0);
> + free_irq(privdata->dev_irq, privdata);
> pci_clear_master(pci_dev);
>
> amd_mp2_clear_reg(privdata);
> diff --git a/drivers/i2c/busses/i2c-amd-mp2.h b/drivers/i2c/busses/i2c-amd-mp2.h
> index ddecd0c88656..018a42de8b1e 100644
> --- a/drivers/i2c/busses/i2c-amd-mp2.h
> +++ b/drivers/i2c/busses/i2c-amd-mp2.h
> @@ -183,6 +183,7 @@ struct amd_mp2_dev {
> struct mutex c2p_lock;
> u8 c2p_lock_busid;
> unsigned int probed;
> + int dev_irq;
> };
>
> /* PCIe communication driver */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports
2022-10-25 18:11 [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports Raju Rangoju
2022-10-28 3:58 ` Shyam Sundar S K
@ 2022-11-01 12:33 ` Wolfram Sang
2022-11-01 12:42 ` Wolfram Sang
1 sibling, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2022-11-01 12:33 UTC (permalink / raw)
To: Raju Rangoju
Cc: syniurge, shyam-sundar.s-k, linux-i2c, linux-kernel,
rajesh1.kumar, Basavaraj Natikar
[-- Attachment #1: Type: text/plain, Size: 464 bytes --]
On Tue, Oct 25, 2022 at 11:41:24PM +0530, Raju Rangoju wrote:
> Use msix or msi interrupts if the hardware supports it. Else, fallback to
> legacy interrupts.
>
> Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
> 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>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports
2022-11-01 12:33 ` Wolfram Sang
@ 2022-11-01 12:42 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2022-11-01 12:42 UTC (permalink / raw)
To: Raju Rangoju, syniurge, shyam-sundar.s-k, linux-i2c, linux-kernel,
rajesh1.kumar, Basavaraj Natikar
[-- Attachment #1: Type: text/plain, Size: 150 bytes --]
> > Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
I dropped this Fixes tag, though. Looks like a new feature to me.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-01 12:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-25 18:11 [PATCH] i2c: amd-mp2: use msix/msi if the hardware supports Raju Rangoju
2022-10-28 3:58 ` Shyam Sundar S K
2022-11-01 12:33 ` Wolfram Sang
2022-11-01 12:42 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox