All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Li Li <r64360@freescale.com>
Cc: linuxppc-dev <linuxppc-dev@ozlabs.org>,
	Gala Kumar <kumar.gala@freescale.com>,
	Li Tony <Tony.Li@freescale.com>
Subject: Re: [PATCH] Add IPIC MSI interrupt support
Date: Tue, 04 Dec 2007 16:38:09 +1100	[thread overview]
Message-ID: <1196746689.20158.4.camel@concordia> (raw)
In-Reply-To: <1196672870.14353.21.camel@Guyver>

[-- Attachment #1: Type: text/plain, Size: 3172 bytes --]

On Mon, 2007-12-03 at 17:07 +0800, Li Li wrote:
> Hi Michael,
> 
> I emulate mpic to write this IPIC MSI routines. :)
> 
> 
> > > diff --git a/arch/powerpc/platforms/83xx/mpc837x_mds.c b/arch/powerpc/platforms/83xx/mpc837x_mds.c
> > > index 6048f1b..dbea34b 100644
> > > --- a/arch/powerpc/platforms/83xx/mpc837x_mds.c
> > > +++ b/arch/powerpc/platforms/83xx/mpc837x_mds.c

> > > +
> > > +#define	ipic_msi_irq_to_hw(virq)	((unsigned int)irq_map[virq].hwirq)
> > 
> > What's wrong with virq_to_hw() ?
> > 
> 
> viqr_to_hw is not __inline__.

Hmm, ok. The three places you use it you also take a spin lock, so I'm
not sure the function call's really going to kill you performance wise.

> > > +
> > > +static void ipic_msi_compose_msg(struct ipic_msi *msi, int hwirq,
> > > +						struct msi_msg *msg)
> > > +{
> > > +	unsigned int srs;
> > > +	unsigned int ibs;
> > > +
> > > +	srs = hwirq / msi->int_per_msir;
> > > +	ibs = hwirq - srs * msi->int_per_msir;
> > > +
> > > +	msg->address_lo = msi->msi_addr_lo;
> > > +	msg->address_hi = msi->msi_addr_hi;
> > > +	msg->data = (srs << 5) | (ibs & 0x1F);
> > > +
> > > +	pr_debug("%s: allocated srs: %d, ibs: %d\n",
> > > +		__FUNCTION__, srs, ibs);
> > > +
> > > +}
> > > +
> > > +static int ipic_msi_setup_irqs(struct pci_dev *pdev, int nvec, int type)
> > > +{
> > > +	struct ipic_msi *msi = ipic_msi;
> > > +	irq_hw_number_t hwirq;
> > > +	unsigned int virq;
> > > +	struct msi_desc *entry;
> > > +	struct msi_msg msg;
> > > +
> > > +	list_for_each_entry(entry, &pdev->msi_list, list) {
> > > +		hwirq = ipic_msi_alloc_hwirqs(msi, 1);
> > > +		if (hwirq < 0) {
> > > +			pr_debug("%s: fail allocating msi interrupt\n",
> > > +					__FUNCTION__);
> > > +			return hwirq;
> > > +		}
> > > +
> > > +		/* This hwirq belongs to the irq_host other than irq_host of IPIC
> > > + 		 * So, it is independent to hwirq of IPIC */
> > > +		virq = irq_create_mapping(msi->irqhost, hwirq);
> > > +		if (virq == NO_IRQ) {
> > > +			pr_debug("%s: fail mapping hwirq 0x%lx\n",
> > > +					__FUNCTION__, hwirq);
> > > +			ipic_msi_free_hwirqs(msi, hwirq, 1);
> > > +			return -ENOSPC;
> > > +		}
> > > +		set_irq_msi(virq, entry);
> > > +		ipic_msi_compose_msg(msi, hwirq, &msg);
> > > +		write_msi_msg(virq, &msg);
> > > +
> > > +		hwirq++;
> > 
> >                   ^^^^ this looks like my bug
> 
> I have a question here. Do we support more MSI interrupts on ONE pci
> device?

I'm not sure what you mean? For MSI there is only one MSI per device,
but this code is used also for MSI-X which supports > 1 MSI per device.

Either way we shouldn't be incrementing hwirq by hand, it's reassigned
at the top of the loop. I think that's left over from old code that
allocated nvec hwirqs in a block and then created virq mappings for each
one, whereas the new code allocates each hwirq separately.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2007-12-04  5:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-30  3:48 [PATCH] Add IPIC MSI interrupt support Li Li
2007-12-03  1:52 ` David Gibson
2007-12-03  4:59   ` Li Li
2007-12-03  4:02 ` Michael Ellerman
2007-12-03  9:07   ` Li Li
2007-12-03 21:03     ` Benjamin Herrenschmidt
2007-12-04  1:41       ` Li Li
2007-12-04  5:38     ` Michael Ellerman [this message]
2007-12-04  7:51       ` Benjamin Herrenschmidt
2007-12-04  9:10         ` Li Li
2007-12-04 10:34       ` Li Tony
2007-12-04 12:04         ` Michael Ellerman
2007-12-04 13:13           ` Scott Wood

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=1196746689.20158.4.camel@concordia \
    --to=michael@ellerman.id.au \
    --cc=Tony.Li@freescale.com \
    --cc=kumar.gala@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=r64360@freescale.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 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.