From: Scott Wood <scottwood@freescale.com>
To: Alexander Graf <agraf@suse.de>
Cc: "qemu-ppc@nongnu.org List" <qemu-ppc@nongnu.org>,
qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 3/5] PPC: E500: Generate dt pci irq map dynamically
Date: Wed, 12 Dec 2012 18:20:59 -0600 [thread overview]
Message-ID: <1355358059.28445.20@snotra> (raw)
In-Reply-To: <A7170C88-AB41-4D7F-A56C-EA0D5A2D71F3@suse.de> (from agraf@suse.de on Wed Dec 12 18:04:11 2012)
On 12/12/2012 06:04:11 PM, Alexander Graf wrote:
>
> On 13.12.2012, at 00:43, Scott Wood wrote:
>
> > On 12/12/2012 05:38:32 PM, Alexander Graf wrote:
> >> On 12.12.2012, at 19:40, Scott Wood wrote:
> >> > On 12/12/2012 08:09:56 AM, Alexander Graf wrote:
> >> >> + for (slot = first_slot; slot < last_slot; slot++) {
> >> >> + for (pci_irq = 0; pci_irq < 4; pci_irq++) {
> >> >> + pci_map[i++] = cpu_to_be32(slot << 11);
> >> >> + pci_map[i++] = cpu_to_be32(0x0);
> >> >> + pci_map[i++] = cpu_to_be32(0x0);
> >> >> + pci_map[i++] = cpu_to_be32(pci_irq + 1);
> >> >> + pci_map[i++] = cpu_to_be32(mpic);
> >> >> + pci_map[i++] = cpu_to_be32(((pci_irq + slot) % 4)
> + 1);
> >> >> + pci_map[i++] = cpu_to_be32(0x1);
> >> >> + }
> >> >> }
> >> >
> >> > It would be nice if the slot-to-IRQ calculation were done in
> only one place rather than duplicated here.
> >> Sure, what exactly would you suggest to do? :)
> >
> > Have a common function to calculate the IRQ given the slot number,
> and call that both from here and from mpc85xx_pci_map_irq().
> >
> >> We can move the whole function to ppce500_pci.c.
> >> We could export the function(slot, pci_irq) through the header of
> ppce500_pci.c.
> >
> > Either works, though I'd lean towards moving this function into
> ppce500_pci.c.
>
> Well, I'm not sure Anthony would be happy about that. He wanted to
> keep device tree generation inside the machine files.
Sigh. I don't understand the hostility to device tree generation, to
the point of enforcing unnatural code grouping and possibly even
duplication.
> But this one might be an exception, because it's not a generic device.
So what happens when we do have a generic device? Duplicate the code
in every machine that uses it, or have a parallel "hw/device_dt.c" (or
maybe some better hidden place) to factor out common code while (sort
of) complying with Anthony's mandate? :-P
> >> We could also try and traverse the pci bus to find the function
> that is actually called to convert irq numbers internally, so we
> potentially support other pci host controllers.
> >
> > Not sure what you mean here.
>
> We could call bus->map_irq(...) with an artificially created
> PCIDevice struct ;). But that's pretty hacky.
If we do anything like that, it should probably be to iterate over the
devices that actually exist and add interrupt-map entries only for
those.
> So you're indicating you'd like the below patch?
I think you pasted a bit more than one patch, but yes.
> Do you think it's worth the additional code for a simple + and & 3?
It's not about duplicating "+ and & 3" so much as having only one place
where the relationship is defined, in case someone wants to alter it
(e.g. for adding some other board where the mapping is done
differently).
> agraf@lychee:/home/agraf/release/qemu> git add hw/ppce500_pci.h
> agraf@lychee:/home/agraf/release/qemu> git diff HEAD
> agraf@lychee:/home/agraf/release/qemu> git diff HEAD | cat
What does piping through cat get you?
-Scott
next prev parent reply other threads:[~2012-12-13 0:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-12 14:09 [Qemu-devel] [PATCH 0/5] PPC: e500: Enable more PCI slots for -M ppce500 Alexander Graf
2012-12-12 14:09 ` [Qemu-devel] [PATCH 1/5] PPC: E500: PCI: Make first slot qdev settable Alexander Graf
2012-12-12 14:09 ` [Qemu-devel] [PATCH 2/5] PPC: E500: PCI: Make IRQ calculation more generic Alexander Graf
2012-12-12 14:09 ` [Qemu-devel] [PATCH 3/5] PPC: E500: Generate dt pci irq map dynamically Alexander Graf
2012-12-12 18:40 ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2012-12-12 23:38 ` Alexander Graf
2012-12-12 23:43 ` Scott Wood
2012-12-13 0:04 ` Alexander Graf
2012-12-13 0:20 ` Scott Wood [this message]
2012-12-13 0:28 ` Alexander Graf
2012-12-13 0:33 ` Scott Wood
2012-12-13 0:36 ` Alexander Graf
2012-12-12 14:09 ` [Qemu-devel] [PATCH 4/5] PPC: E500: Move PCI slot information into params Alexander Graf
2012-12-12 14:09 ` [Qemu-devel] [PATCH 5/5] PPC: E500plat: Make a lot of PCI slots available Alexander Graf
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=1355358059.28445.20@snotra \
--to=scottwood@freescale.com \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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;
as well as URLs for NNTP newsgroup(s).