public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: "Krzysztof Wilczyński" <kw@linux.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Niklas Cassel <cassel@kernel.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Damien Le Moal <dlemoal@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: dwc: ep: Do not map more memory than needed to raise a MSI/MSI-X IRQ
Date: Sun, 17 Nov 2024 03:37:52 +0900	[thread overview]
Message-ID: <20241116183752.GB890334@rocinante> (raw)
In-Reply-To: <20241115071924.jn3xun6luqzd2ylp@thinkpad>

Hello,

> > In dw_pcie_ep_init() we allocate memory from the EPC address space that we
> > will later use to raise a MSI/MSI-X IRQ. This memory is only freed in
> > dw_pcie_ep_deinit().
> > 
> > Performing this allocation in dw_pcie_ep_init() is to ensure that we will
> > not fail to allocate memory from the EPC address space when trying to raise
> > a MSI/MSI-X IRQ.
> > 
> > We still map/unmap this memory every time we raise an IRQ, in order to not
> > constantly occupy an iATU, especially for controllers with few iATUs.
> > (So we can still fail to raise an MSI/MSI-X IRQ if all iATUs are occupied.)
> > 
> > When allocating this memory in dw_pcie_ep_init(), we allocate
> > epc->mem->window.page_size memory, which is the smallest unit that we can
> > allocate from the EPC address space.
> > 
> > However, when writing/sending the msg data, which is only 2 bytes for MSI,
> > 4 bytes for MSI-X, in either case a single writel() is sufficient. Thus,
> > the size that we need to map is a single PCI DWORD (4 bytes).
> > 
> > This is the size that we should send in to the pci_epc_ops::align_addr()
> > API. It is align_addr()'s responsibility to return a size that is aligned
> > to the EPC page size, for platforms that need a special alignment.
> > 
> > Modify the align_addr() call to send in the proper size that we need to
> > map.
> > 
> > Before this patch on a system with a EPC page size 64k, we would
> > incorrectly map 128k (which is larger than our allocation) instead of 64k.
> > 
> > After this patch, we will correctly map 64k (a single page). (We should
> > never need to map more than a page to write a single DWORD.)
> > 
> > Fixes: f68da9a67173 ("PCI: dwc: ep: Use align addr function for dw_pcie_ep_raise_{msi,msix}_irq()")
> > Signed-off-by: Niklas Cassel <cassel@kernel.org>
> 
> FWIW,
> 
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Picked this tag, too.  Thank you!

	Krzysztof

      reply	other threads:[~2024-11-16 18:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 20:51 [PATCH] PCI: dwc: ep: Do not map more memory than needed to raise a MSI/MSI-X IRQ Niklas Cassel
2024-11-04 21:13 ` Krzysztof Wilczyński
2024-11-04 22:04   ` Niklas Cassel
2024-11-04 22:38     ` Krzysztof Wilczyński
2024-11-15  7:19 ` Manivannan Sadhasivam
2024-11-16 18:37   ` Krzysztof Wilczyński [this message]

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=20241116183752.GB890334@rocinante \
    --to=kw@linux.com \
    --cc=Frank.Li@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --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