qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	Avi Kivity <avi@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 01/15] pc: merge pc_piix.c into pc.c
Date: Fri, 27 Jan 2012 08:06:50 -0600	[thread overview]
Message-ID: <4F22AF7A.6040601@us.ibm.com> (raw)
In-Reply-To: <4F22A777.5010806@siemens.com>

On 01/27/2012 07:32 AM, Jan Kiszka wrote:
> On 2012-01-27 14:07, Anthony Liguori wrote:
>> On 01/27/2012 02:50 AM, Jan Kiszka wrote:
>>> On 2012-01-26 20:00, Anthony Liguori wrote:
>>>> A long time ago, there was a grand plan to merge q35 chipset support.  The start
>>>> of that series was a refactoring of pc.c which split a bunch of the "common"
>>>> functionality into a separate file that could be shared by the two.
>>>>
>>>> But q35 never got merged and the refactoring, in retrospect, just made things
>>>> worse.  Making things proper objects and using composition is the right way
>>>> to share common devices.
>>>>
>>>> By pulling these files back together, we can start to fix some of this mess.
>>>
>>> There are surely things to clean up and improve, but a clear NACK for
>>> the general direction.
>>
>> Hi Jan,
>>
>> I think you're missing the bigger picture here.  Once this refactoring finishes,
>> here's what we'll be left with:
>>
>> 1) pc_init creates an I440FX, any bus devices (ISA serial port, PCI vga and
>> nics, etc.), sets properties appropriately, and realizes the devices.
>>
>> 2) I440FX is-a PCIHost, has-a I440FX-PMC, has-a PIIX3
>>
>> 3) PIIX3 has-a RTC, has-a I8042, has-a DMAController, etc.
>>
>> Memory creation is done by the I440FX-PMC.
>>
>> Now it's true that a newer chipset is going to be similar.  It will likely have
>> a SuperI/O chip that looks similar to PIIX3.  The right way to share code would
>> be to move most of the PIIX3 functionality to a base class (PCSuperIO) that
>> PIIX3 inherits from.
>>
>> This is probably how to support ISAPC properly too.
>
> The ISAPC is differently composed. The board creates all those
> individual chips that are otherwise part of the SuperIO block of the
> chipset. And IRQ wiring is different.

A SuperIO device can still have irq properties for each device that determines 
which ISA bus irq is used.

The other alternative is to stop making devices ISADevice, and then having 
SuperIO expose a bunch of device specific IRQs.  Those IRQs can then be routed 
in whatever way makes sense.

This is really the Right Approach but it's most likely a compatibility breaker 
so I'm trying my best to avoid these types of refactorings right now.

> So, no, I don't think it is the
> right model. I would rather think of a pc_isa.c that does the proper
> composing.

Objects compose other objects.  Functions should not be creating devices.  So if 
you're view of pc_isa.c that there's a pc_basic_init() that takes a bunch of 
devicestate pointers, then that's definitely not the direction I'm heading.

Note that if we ever want to get to a board configuration file, we need to have 
three explicit steps in device creation:

1) device initialization where devices are allocates and the composition tree is 
filled out (which makes sure that every device has an addressable path)

2) device property setting (which requires all devices have an addressable path)

3) device realization where property settings are validated, and then any 
initialization that depends on properties is done.

The problem with the current code is that it doesn't split up these phases. 
Modeling composition really helps to get this split because it forces you to 
think about things in terms of distinct phases.

>>   Once I sort out interrupts,
>> I'll attempt to tackle that.  My guess is that a SuperIO chip could be an
>> ISADevice and that we could simply make the PIIX3 has-a SuperIO.  Then the ISAPC
>> would have a trivial ISA chipset that has-a SuperIO.
>>
>> This is fairly trivial to do once we have the right structure to the code.
>>
>> But the current code has the wrong structure which is why there's so much
>> pointer chasing and passing.
>
> Just look at your code and count the generic, PIIX3-independent
> functions.

I see zero.

"PIIX3-independent" means that some other piece of code would consume it in 
exactly the same way.  pc.c had a bunch of spaghetti in it doing tricks with if 
(pci_enabled) that ended up encoding two very separate paths into one maze of code.

> Keep them in pc.c, move the rest to pc_piix.c. You could try
> to model the ISA accordingly. I think some pc_isa.c would help to
> establish a good split-up already now, in the absence of a third chipset.

I think creating a proper ISA model is a good idea and I'll certainly get there.

Regards,

Anthony Liguori

>>
>>>
>>> It's undoubted that we need a more modern chipset than this ancient
>>> PIIX3, rather sooner than later. And it is clear that there is a good
>>> amount of generic functions in pc.c for building a PC, even a fairly
>>> modern one. So we need a common lib for PC chipsets and would only
>>> revert what you start here.
>>
>> Sorry, but I don't view this as a useful requirement.  Today we support two
>> types of PCs: an i440fx based system and an ISA-only system.  We should
>> concentrate on modeling those two systems in the most natural way sharing as
>> much code as possible.
>
> A modern chipset is the only sane way to add things like PCIe,
> hotplugging, power management, etc., and to enable standard PC
> components like AHCI or EHCI/xHCI by default.
>
> Jan
>

  reply	other threads:[~2012-01-27 14:14 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 19:00 [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 01/15] pc: merge pc_piix.c into pc.c Anthony Liguori
2012-01-26 19:40   ` Anthony Liguori
2012-01-27  8:50   ` Jan Kiszka
2012-01-27 13:07     ` Anthony Liguori
2012-01-27 13:32       ` Jan Kiszka
2012-01-27 14:06         ` Anthony Liguori [this message]
2012-01-27 14:15           ` Jan Kiszka
2012-01-27 14:23             ` Anthony Liguori
2012-01-27 14:03       ` Andreas Färber
2012-01-27 14:14         ` Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 02/15] pc: make some functions static Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 03/15] piix3: make PIIX3-xen a subclass of PIIX3 Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 04/15] piix: prepare for composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 05/15] piix: create the HPET and RTC through composition Anthony Liguori
2012-01-31 14:26   ` Jan Kiszka
2012-01-31 14:43     ` Anthony Liguori
2012-01-31 14:49       ` Jan Kiszka
2012-01-31 14:54         ` Anthony Liguori
2012-01-31 14:56           ` Jan Kiszka
2012-01-31 15:04             ` Anthony Liguori
2012-01-31 16:02     ` Jan Kiszka
2012-01-26 19:00 ` [Qemu-devel] [PATCH 06/15] piix: create i8254 " Anthony Liguori
2012-01-31 14:34   ` Jan Kiszka
2012-01-31 14:47     ` Anthony Liguori
2012-01-31 14:51       ` Jan Kiszka
2012-01-31 14:56         ` Anthony Liguori
2012-01-31 16:42           ` Jan Kiszka
2012-01-31 16:49             ` Anthony Liguori
2012-01-31 16:56               ` Jan Kiszka
2012-01-31 14:58         ` Paolo Bonzini
2012-01-31 16:04           ` Jan Kiszka
2012-01-31 16:12           ` Anthony Liguori
2012-01-31 16:19             ` Jan Kiszka
2012-01-31 16:47               ` Anthony Liguori
2012-01-31 16:59                 ` Paolo Bonzini
2012-01-26 19:00 ` [Qemu-devel] [PATCH 07/15] i440fx: eliminate i440fx_common_init Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 08/15] i440fx: introduce some saner naming conventions Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 09/15] i440fx: create the PMC through composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 10/15] i440fx: move some logic to realize and make inheritance from PCIHost explicit Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 11/15] i440fx-pmc: refactor to take properties for memory geometry Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 12/15] i440fx-pmc: calculate PCI memory hole directly Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 13/15] i440fx: allocate MemoryRegion for pci memory space Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 14/15] i440fx: move bios loading to i440fx Anthony Liguori
2012-01-31 14:38   ` Jan Kiszka
2012-01-31 14:50     ` Anthony Liguori
2012-01-31 14:53       ` Jan Kiszka
2012-01-31 14:57         ` Anthony Liguori
2012-01-31 15:01           ` Jan Kiszka
2012-01-26 19:01 ` [Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-pmc Anthony Liguori
2012-01-26 19:12 ` [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Peter Maydell
2012-01-26 19:36   ` Anthony Liguori
2012-01-29 10:42     ` Avi Kivity
2012-01-26 19:57   ` Markus Armbruster
2012-01-26 20:00     ` Anthony Liguori

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=4F22AF7A.6040601@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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).