linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Jingoo Han <jingoohan1@gmail.com>,
	Pratyush Anand <pratyush.anand@gmail.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: pcie-designware msi_controller->dev handling
Date: Fri, 5 Aug 2016 17:50:55 +0200	[thread overview]
Message-ID: <20160805175055.3e8800b8@free-electrons.com> (raw)

Jingoo, Pratyush,

I was going to some of the MSI handling code in the pcie-designware
driver, and stumbled across the following part of the code:

static struct msi_controller dw_pcie_msi_chip = {
	.setup_irq = dw_msi_setup_irq,
	.setup_irqs = dw_msi_setup_irqs,
	.teardown_irq = dw_msi_teardown_irq,
};

[...]

int dw_pcie_host_init(struct pcie_port *pp)
{
	[...]

	if (IS_ENABLED(CONFIG_PCI_MSI)) {
		bus = pci_scan_root_bus_msi(pp->dev, pp->root_bus_nr,
					    &dw_pcie_ops, pp, &res,
					    &dw_pcie_msi_chip);
		dw_pcie_msi_chip.dev = pp->dev;
	[...]
}

I am a bit surprised by the dw_pcie_msi_chip.dev assignment here.
Indeed, there is only one global dw_pcie_msi_chip structure, but the
function dw_pcie_host_init() can be called several times, once for each
PCIe controller available on a platform.

This means that the dw_pcie_msi_chip.dev will point to the last
Designware PCIe controller that was registered.

If the MSI controller is indeed part of the PCIe controller IP, I think
the msi_controller structure needs to be dynamically allocated, so that
you have one instance for each PCIe controller.

Am I missing something?

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

             reply	other threads:[~2016-08-05 15:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 15:50 Thomas Petazzoni [this message]
2016-08-14 16:14 ` pcie-designware msi_controller->dev handling Pratyush Anand

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=20160805175055.3e8800b8@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=bhelgaas@google.com \
    --cc=jingoohan1@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=pratyush.anand@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).