2017-06-20 00:00:01

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 15/55] PCI: vmd: Create named irq domain

Use the fwnode to create a named domain so diagnosis works.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Keith Busch <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: [email protected]
---
drivers/pci/host/vmd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/pci/host/vmd.c
+++ b/drivers/pci/host/vmd.c
@@ -554,6 +554,7 @@ static int vmd_find_free_domain(void)
static int vmd_enable_domain(struct vmd_dev *vmd)
{
struct pci_sysdata *sd = &vmd->sysdata;
+ struct fwnode_handle *fn;
struct resource *res;
u32 upper_bits;
unsigned long flags;
@@ -617,8 +618,13 @@ static int vmd_enable_domain(struct vmd_

sd->node = pcibus_to_node(vmd->dev->bus);

- vmd->irq_domain = pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info,
+ fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
+ if (!fn)
+ return -ENODEV;
+
+ vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
x86_vector_domain);
+ kfree(fn);
if (!vmd->irq_domain)
return -ENODEV;




2017-06-20 19:59:47

by Keith Busch

[permalink] [raw]
Subject: Re: [patch 15/55] PCI: vmd: Create named irq domain

On Tue, Jun 20, 2017 at 01:37:15AM +0200, Thomas Gleixner wrote:
> static int vmd_enable_domain(struct vmd_dev *vmd)
> {
> struct pci_sysdata *sd = &vmd->sysdata;
> + struct fwnode_handle *fn;
> struct resource *res;
> u32 upper_bits;
> unsigned long flags;
> @@ -617,8 +618,13 @@ static int vmd_enable_domain(struct vmd_
>
> sd->node = pcibus_to_node(vmd->dev->bus);
>
> - vmd->irq_domain = pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info,
> + fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
> + if (!fn)
> + return -ENODEV;
> +
> + vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
> x86_vector_domain);
> + kfree(fn);

If I'm following all this correctly, it looks like we need to use
irq_domain_free_fwnode with irq_domain_alloc_named_id_fwnode instead of
freeing 'fn' directly, otherwise we leak 'fwid->name'.

2017-06-20 20:07:30

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch 15/55] PCI: vmd: Create named irq domain

On Tue, 20 Jun 2017, Keith Busch wrote:
> On Tue, Jun 20, 2017 at 01:37:15AM +0200, Thomas Gleixner wrote:
> > static int vmd_enable_domain(struct vmd_dev *vmd)
> > {
> > struct pci_sysdata *sd = &vmd->sysdata;
> > + struct fwnode_handle *fn;
> > struct resource *res;
> > u32 upper_bits;
> > unsigned long flags;
> > @@ -617,8 +618,13 @@ static int vmd_enable_domain(struct vmd_
> >
> > sd->node = pcibus_to_node(vmd->dev->bus);
> >
> > - vmd->irq_domain = pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info,
> > + fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
> > + if (!fn)
> > + return -ENODEV;
> > +
> > + vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
> > x86_vector_domain);
> > + kfree(fn);
>
> If I'm following all this correctly, it looks like we need to use
> irq_domain_free_fwnode with irq_domain_alloc_named_id_fwnode instead of
> freeing 'fn' directly, otherwise we leak 'fwid->name'.

Yes, I'm a moron.

2017-06-20 20:39:49

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch 15/55] PCI: vmd: Create named irq domain

On Tue, 20 Jun 2017, Thomas Gleixner wrote:
> On Tue, 20 Jun 2017, Keith Busch wrote:
> > On Tue, Jun 20, 2017 at 01:37:15AM +0200, Thomas Gleixner wrote:
> > > static int vmd_enable_domain(struct vmd_dev *vmd)
> > > {
> > > struct pci_sysdata *sd = &vmd->sysdata;
> > > + struct fwnode_handle *fn;
> > > struct resource *res;
> > > u32 upper_bits;
> > > unsigned long flags;
> > > @@ -617,8 +618,13 @@ static int vmd_enable_domain(struct vmd_
> > >
> > > sd->node = pcibus_to_node(vmd->dev->bus);
> > >
> > > - vmd->irq_domain = pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info,
> > > + fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
> > > + if (!fn)
> > > + return -ENODEV;
> > > +
> > > + vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
> > > x86_vector_domain);
> > > + kfree(fn);
> >
> > If I'm following all this correctly, it looks like we need to use
> > irq_domain_free_fwnode with irq_domain_alloc_named_id_fwnode instead of
> > freeing 'fn' directly, otherwise we leak 'fwid->name'.
>
> Yes, I'm a moron.

Fixed up the mess and updated the git branch.

Thanks for catching it.

tglx

Subject: [tip:irq/core] PCI/vmd: Create named irq domain

Commit-ID: ae904cafd59d7120ef2afb97b252eadeba45e95f
Gitweb: http://git.kernel.org/tip/ae904cafd59d7120ef2afb97b252eadeba45e95f
Author: Thomas Gleixner <[email protected]>
AuthorDate: Tue, 20 Jun 2017 01:37:15 +0200
Committer: Thomas Gleixner <[email protected]>
CommitDate: Thu, 22 Jun 2017 18:21:12 +0200

PCI/vmd: Create named irq domain

Use the fwnode to create a named domain so diagnosis works.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Marc Zyngier <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Keith Busch <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: Bjorn Helgaas <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]

---
drivers/pci/host/vmd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/host/vmd.c b/drivers/pci/host/vmd.c
index e27ad2a..31203d6 100644
--- a/drivers/pci/host/vmd.c
+++ b/drivers/pci/host/vmd.c
@@ -554,6 +554,7 @@ static int vmd_find_free_domain(void)
static int vmd_enable_domain(struct vmd_dev *vmd)
{
struct pci_sysdata *sd = &vmd->sysdata;
+ struct fwnode_handle *fn;
struct resource *res;
u32 upper_bits;
unsigned long flags;
@@ -617,8 +618,13 @@ static int vmd_enable_domain(struct vmd_dev *vmd)

sd->node = pcibus_to_node(vmd->dev->bus);

- vmd->irq_domain = pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info,
+ fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
+ if (!fn)
+ return -ENODEV;
+
+ vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
x86_vector_domain);
+ irq_domain_free_fwnode(fn);
if (!vmd->irq_domain)
return -ENODEV;