From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxsYG-0004ey-5n for qemu-devel@nongnu.org; Fri, 20 Jun 2014 02:44:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxsY4-0003vn-CY for qemu-devel@nongnu.org; Fri, 20 Jun 2014 02:43:56 -0400 Received: from mail-ve0-f175.google.com ([209.85.128.175]:55143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxsY4-0003vP-71 for qemu-devel@nongnu.org; Fri, 20 Jun 2014 02:43:44 -0400 Received: by mail-ve0-f175.google.com with SMTP id jx11so3249244veb.34 for ; Thu, 19 Jun 2014 23:43:43 -0700 (PDT) MIME-Version: 1.0 Sender: peter.crosthwaite@petalogix.com In-Reply-To: <1401884936-12907-1-git-send-email-agraf@suse.de> References: <1401884936-12907-1-git-send-email-agraf@suse.de> Date: Fri, 20 Jun 2014 16:43:42 +1000 Message-ID: From: Peter Crosthwaite Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH 0/5] Platform device support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf , Paolo Bonzini Cc: qemu-ppc Mailing List , "qemu-devel@nongnu.org Developers" , Eric Auger On Wed, Jun 4, 2014 at 10:28 PM, Alexander Graf wrote: > Platforms without ISA and/or PCI have had a seriously hard time in the dynamic > device creation world of QEMU. Devices on these were modeled as SysBus devices > which can only be instantiated in machine files, not through -device. > > Why is that so? > > Well, SysBus is trying to be incredibly generic. It allows you to plug any > interrupt sender into any other interrupt receiver. It allows you to map > a device's memory regions into any other random memory region. All of that > only works from C code or via really complicated command line arguments under > discussion upstream right now. > What you are doing seem to me to be an extension of SysBus - you are defining the same interfaces as sysbus but also adding some machine specifics wiring info. I think it's a candidate for QOM inheritance to avoid having to dup all the sysbus device models for both regular sysbus and platform bus. I think your functionality should be added as one of 1: and interface that can be added to sysbus devices 2: a new abstraction that inherits from SYS_BUS_DEVICE 3: just new features to the sysbus core. Then both of us are using the same suite of device models and the differences between our approaches are limited to machine level instantiation method. My gut says #2 is the cleanest. > But do we need that level of complexity for normal devices usually? In a > normal platform world (SoCs, PV machines) we have a flat memory layout we > can plug our device memory into. We also have a flat IRQ model where we > can plug our device IRQs into. > > So the idea for platform devices arose. A platform device is really just a > device that exposes its qemu_irq slots and memory regions to the world. > > That allows us to write machine specific code that maps a platform device > wherever the machine thinks fits nicely. It also allows that same machine > to generate a device tree entry for platform devices easily, as it is fully > aware of the interrupt lines and places it was mapped to. > > A device (read: user) may or may not explictly request to be mapped at a > specific IRQ and/or memory address. If no explicit mapping is requested, > platform devices can get mapped at convenient places by the machine. > > The actual pressing issue this solves is that today it's impossible to spawn > serial ports from the command line. With this patch set, it's possible to > do so. But it lays the groundwork for much more... > > Alexander Graf (5): > Platform: Add platform device class > Platform: Add serial device > PPC: e500: Only create dt entries for existing serial ports > PPC: e500: Support platform devices > PPC: e500: Add support for platform serial devices > > default-configs/ppc-softmmu.mak | 2 + > default-configs/ppc64-softmmu.mak | 2 + > hw/Makefile.objs | 1 + > hw/char/Makefile.objs | 1 + > hw/char/serial-platform.c | 103 +++++++++++++++ I think a big point of confusion here is you have picked a not-even-qdevified device for conversion. Boards are still calling serial_mm_init() directly due to lack of a proper device for Sysbus serial. Do you have another device that already QOMified (a MAC or something perhaps?) that you can convert more minimally to demonstrate the approach for existing sysbus devs? Sysbusification of serial would then be a step towards platform-device serial. Regards, Peter > hw/platform/Makefile.objs | 1 + > hw/platform/device.c | 108 ++++++++++++++++ > hw/ppc/e500.c | 262 +++++++++++++++++++++++++++++++++++++- > hw/ppc/e500.h | 1 + > hw/ppc/e500plat.c | 1 + > include/hw/char/serial-platform.h | 56 ++++++++ > include/hw/platform/device.h | 45 +++++++ > 12 files changed, 577 insertions(+), 6 deletions(-) > create mode 100644 hw/char/serial-platform.c > create mode 100644 hw/platform/Makefile.objs > create mode 100644 hw/platform/device.c > create mode 100644 include/hw/char/serial-platform.h > create mode 100644 include/hw/platform/device.h > > -- > 1.8.1.4 > >