From: Bjorn Helgaas <bhelgaas@google.com>
To: Lucas Stach <l.stach@pengutronix.de>
Cc: Mohit Kumar <mohit.kumar@st.com>,
Jingoo Han <jg1.han@samsung.com>,
kernel@pengutronix.de, linux-pci@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 2/2] PCI: designware: implement multiple MSI irq setup
Date: Wed, 8 Apr 2015 13:54:38 -0500 [thread overview]
Message-ID: <20150408185438.GB30967@google.com> (raw)
In-Reply-To: <1427714234.3370.8.camel@pengutronix.de>
[+cc Thomas]
[Thomas, this is just FYI. The previous patch adds
+ int (*setup_irqs)(struct msi_controller *chip, struct pci_dev *dev,
+ int nvec, int type);
to struct msi_controller.]
On Mon, Mar 30, 2015 at 01:17:14PM +0200, Lucas Stach wrote:
> Am Freitag, den 20.03.2015, 17:07 -0500 schrieb Bjorn Helgaas:
> > On Mon, Mar 09, 2015 at 06:33:08PM +0100, Lucas Stach wrote:
> > > Allows to properly set up multiple MSI irqs per device.
> > >
> > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > ---
> > > The ifdef is needed to avoid a compile error on
> > > !CONFIG_PCI_MSI, as msi_list is only part of pci_dev
> > > when the kernel is compiled with MSI support.
> > > ---
> > > drivers/pci/host/pcie-designware.c | 46 ++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 46 insertions(+)
> > >
> > > diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
> > > index 1f4ea6f2d910..8a15ea2e8eab 100644
> > > --- a/drivers/pci/host/pcie-designware.c
> > > +++ b/drivers/pci/host/pcie-designware.c
> > > @@ -269,6 +269,9 @@ static int assign_irq(int no_irqs, struct msi_desc *desc, int *pos)
> > > }
> > >
> > > *pos = pos0;
> > > + desc->nvec_used = no_irqs;
> > > + desc->msi_attrib.multiple = order_base_2(no_irqs);
> > > +
> > > return irq;
> > >
> > > no_valid_irq:
> > > @@ -305,6 +308,48 @@ static int dw_msi_setup_irq(struct msi_controller *chip, struct pci_dev *pdev,
> > >
> > > return 0;
> > > }
> > > +#ifdef CONFIG_PCI_MSI
> > > +static int dw_msi_setup_irqs(struct msi_controller *chip, struct pci_dev *pdev,
> > > + int nvec, int type)
> > > +{
> > > + int irq, pos;
> > > + struct msi_desc *desc;
> > > + struct msi_msg msg;
> > > + struct pcie_port *pp = sys_to_pcie(pdev->bus->sysdata);
> > > +
> > > + /* MSI-X interrupts are not supported */
> > > + if (type == PCI_CAP_ID_MSIX)
> > > + return -EINVAL;
> > > +
> > > + WARN_ON(!list_is_singular(&pdev->msi_list));
> > > + desc = list_entry(pdev->msi_list.next, struct msi_desc, list);
> > > +
> > > + irq = assign_irq(nvec, desc, &pos);
> > > + if (irq < 0)
> > > + return irq;
> > > +
> > > + if (pp->ops->get_msi_addr)
> > > + msg.address_lo = pp->ops->get_msi_addr(pp);
> > > + else
> > > + msg.address_lo = virt_to_phys((void *)pp->msi_data);
> > > + msg.address_hi = 0x0;
> > > +
> > > + if (pp->ops->get_msi_data)
> > > + msg.data = pp->ops->get_msi_data(pp, pos);
> > > + else
> > > + msg.data = pos;
> > > +
> > > + pci_write_msi_msg(irq, &msg);
> > > +
> > > + return 0;
> > > +}
> > > +#else
> > > +static int dw_msi_setup_irqs(struct msi_chip *chip, struct pci_dev *pdev,
> > > + int nvec, int type)
> > > +{
> > > + return -ENOSYS;
> > > +}
> >
> > Seems strange that we need even this stub function when we don't have
> > CONFIG_PCI_MSI. Is there some way we can fix this so dw_pcie_msi_chip is
> > only defined when we have CONFIG_PCI_MSI?
> >
> I would rather not do this. We try to keep as much code as possible to
> at least see some compile coverage, even if the options are not set by
> using the IS_ENABLED() macro instead of ifdefs. All other MSI related
> code compiles even without CONFIG_PCI_MSI being set.
Is it really a goal to compile code for disabled config options? I see
that a lot of the host drivers do that, especially for MSI-related code,
and the lack of #ifdefs might be an advantage. But I don't think we want
code for disabled config options to appear in the object file, and I'm not
sure it improves readability for human readers who lose the #ifdef clues.
> The problem with the above function is that the msi_list member of
> struct pci_device is only declared if CONFIG_PCI_MSI is set. So of you
> really want to get rid of the above stub, my preferred solution would be
> to remove the ifdef in struct pci_device, so we can compile the code
> regardless of the config options.
No, I don't really want to remove the #ifdef in struct pci_device, because
if CONFIG_PCI_MSI is disabled, there's no reason to include the space in
the structure. For one config option, it's not a big deal, but it doesn't
scale well if we apply the same rule to all config options.
But since these patches don't change the disabled config option strategy,
I'll apply them mostly as-is, given an ack from Mohit and/or Jingoo.
Bjorn
next prev parent reply other threads:[~2015-04-08 18:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 17:33 [PATCH 1/2] PCI: allow MSI chip providers to implement their own multiple MSI setup Lucas Stach
2015-03-09 17:33 ` [PATCH 2/2] PCI: designware: implement multiple MSI irq setup Lucas Stach
2015-03-20 22:07 ` Bjorn Helgaas
2015-03-30 11:17 ` Lucas Stach
2015-04-08 9:10 ` Lucas Stach
2015-04-08 18:54 ` Bjorn Helgaas [this message]
2015-04-08 18:56 ` Bjorn Helgaas
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=20150408185438.GB30967@google.com \
--to=bhelgaas@google.com \
--cc=jg1.han@samsung.com \
--cc=kernel@pengutronix.de \
--cc=l.stach@pengutronix.de \
--cc=linux-pci@vger.kernel.org \
--cc=mohit.kumar@st.com \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.