Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Anand Moon <linux.amoon@gmail.com>
Cc: "Kevin Xie" <kevin.xie@starfivetech.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Minda Chen" <minda.chen@starfivetech.com>,
	"open list:PCIE DRIVER FOR STARFIVE JH71x0"
	<linux-pci@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] PCI: starfive: Fix kmemleak in StarFive PCIe driver's IRQ handling
Date: Mon, 24 Feb 2025 17:24:52 +0530	[thread overview]
Message-ID: <20250224115452.micfqctwjkt6gwrs@thinkpad> (raw)
In-Reply-To: <CANAwSgTsp19ri5SYYtD+VOYgBLYg5UqvGRrtNTXOWw7umxGCQg@mail.gmail.com>

On Mon, Feb 24, 2025 at 03:38:29PM +0530, Anand Moon wrote:
> Hi Manivannan
> 
> On Mon, 24 Feb 2025 at 13:31, Manivannan Sadhasivam
> <manivannan.sadhasivam@linaro.org> wrote:
> >
> > On Thu, Feb 20, 2025 at 03:53:31PM +0530, Anand Moon wrote:
> >
> > [...]
> >
> > > Following the change fix this warning in a kernel memory leak.
> > > Would you happen to have any comments on these changes?
> > >
> > > diff --git a/drivers/pci/controller/plda/pcie-plda-host.c
> > > b/drivers/pci/controller/plda/pcie-plda-host.c
> > > index 4153214ca410..5a72a5a33074 100644
> > > --- a/drivers/pci/controller/plda/pcie-plda-host.c
> > > +++ b/drivers/pci/controller/plda/pcie-plda-host.c
> > > @@ -280,11 +280,6 @@ static u32 plda_get_events(struct plda_pcie_rp *port)
> > >         return events;
> > >  }
> > >
> > > -static irqreturn_t plda_event_handler(int irq, void *dev_id)
> > > -{
> > > -       return IRQ_HANDLED;
> > > -}
> > > -
> > >  static void plda_handle_event(struct irq_desc *desc)
> > >  {
> > >         struct plda_pcie_rp *port = irq_desc_get_handler_data(desc);
> > > @@ -454,13 +449,10 @@ int plda_init_interrupts(struct platform_device *pdev,
> > >
> > >                 if (event->request_event_irq)
> > >                         ret = event->request_event_irq(port, event_irq, i);
> > > -               else
> > > -                       ret = devm_request_irq(dev, event_irq,
> > > -                                              plda_event_handler,
> > > -                                              0, NULL, port);
> >
> > This change is not related to the memleak. But I'd like to have it in a separate
> > patch since this code is absolutely not required, rather pointless.
> >
> Yes, remove these changes to fix the memory leak issue I observed.
> 

Sorry, I don't get you. This specific code change of removing 'devm_request_irq'
is not supposed to fix memleak.

If you are seeing the memleak getting fixed because of it, then something is
wrong with the irq implementation. You need to figure it out.

> > >
> > >                 if (ret) {
> > >                         dev_err(dev, "failed to request IRQ %d\n", event_irq);
> > > +                       irq_dispose_mapping(event_irq);
> >
> > So the issue overall is that the 'devm_request_irq' fails on your platform
> > because the interrupts are not defined in DT and then the IRQ is not disposed in
> > the error path?
> >
> On microchip PCIe driver utilizes interrupt resources from its
> "bridge" and "cntrl"
> components, accessed via ioremap, to handle hardware events.
> These resources are absent in the StarFive PCIe controller.
> 
> While the StarFive JH-7110 datasheet [1] indicates support for PME, MSI, and INT
> messages and specific implementation details for leveraging these interrupts are
> unavailable.
> 
> As per StarFive JH-7110 Datasheet PCI support [1]
> 1 Power Management Event (PME message) ◦
> 2  MSI (up to 32) and INT message support
> 
> [1] https://doc-en.rvspace.org/JH7110/PDF/JH7110I_DS.pdf
> 

Fine.

> > In that case, none of the error paths below for_each_set_bit() loop is disposing
> > the IRQs. Also, calling 'irq_dispose_mapping()' only once is not going to
> > dispose all mappings that were created before in the loop.
> 
> I was looking at how the IRQ error path will clean up IRQ in case of failure
> hence, I added this in case of failure to unmap IRQ events,
> I will drop this if not required.

Absolutely not. These are fixing the irq leaks. But if it is not related to the
'memleak' you observed, then these should be part of a separate patch.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2025-02-24 11:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-08 14:01 [PATCH v1] PCI: starfive: Fix kmemleak in StarFive PCIe driver's IRQ handling Anand Moon
2025-02-08 16:33 ` [PATCH] " Markus Elfring
2025-02-09  4:22   ` Anand Moon
2025-02-10 17:44 ` [PATCH v1] " Manivannan Sadhasivam
2025-02-10 19:39   ` Anand Moon
2025-02-14  6:09     ` Manivannan Sadhasivam
2025-02-20  8:13       ` Anand Moon
2025-02-20 10:23         ` Anand Moon
2025-02-24  8:01           ` Manivannan Sadhasivam
2025-02-24 10:08             ` Anand Moon
2025-02-24 11:54               ` Manivannan Sadhasivam [this message]
2025-02-24 14:03                 ` Anand Moon
2025-02-24 14:41                   ` Manivannan Sadhasivam
2025-02-24 16:07                     ` Anand Moon
2025-03-03 15:23                       ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250224115452.micfqctwjkt6gwrs@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=conor.dooley@microchip.com \
    --cc=kevin.xie@starfivetech.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux.amoon@gmail.com \
    --cc=lpieralisi@kernel.org \
    --cc=minda.chen@starfivetech.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox