From patchwork Thu Jun 11 00:38:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 482943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 07E77140297 for ; Thu, 11 Jun 2015 10:39:08 +1000 (AEST) Received: from localhost ([::1]:42851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2qWQ-00076N-6Y for incoming@patchwork.ozlabs.org; Wed, 10 Jun 2015 20:39:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2qVo-0005uk-CO for qemu-devel@nongnu.org; Wed, 10 Jun 2015 20:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2qVn-0000tp-CY for qemu-devel@nongnu.org; Wed, 10 Jun 2015 20:38:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2qVn-0000tl-7r for qemu-devel@nongnu.org; Wed, 10 Jun 2015 20:38:27 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id DAEE58E667 for ; Thu, 11 Jun 2015 00:38:26 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5B0c62P007219; Wed, 10 Jun 2015 20:38:24 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org, lersek@redhat.com Date: Thu, 11 Jun 2015 02:38:02 +0200 Message-Id: <1433983083-4636-6-git-send-email-lersek@redhat.com> In-Reply-To: <1433983083-4636-1-git-send-email-lersek@redhat.com> References: <1433983083-4636-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Marcel Apfelbaum , Markus Armbruster , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v3 5/6] hw/core: explicit OFW unit address property for SysBusDevice X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The sysbus_get_fw_dev_path() function formats OpenFirmware device path nodes ("driver-name@unit-address") for sysbus devices. The first choice for "unit-address" is the base address of the device's first MMIO region. The second choice is its first IO port. However, if two sysbus devices with the same "driver-name" lack both MMIO and PIO resources, then there is no good way to distinguish them based on their OFW nodes, because in this case unit-address is omitted completely for both devices. For such devices, delegate a fallback property, "explicit_ofw_unit_address", to whoever creates the device. The creator can set the property to any appropriate value. Cc: Markus Armbruster Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek Reviewed-by: Marcel Apfelbaum --- Notes: v3: - new in v3 - new approach include/hw/sysbus.h | 8 ++++++++ hw/core/sysbus.c | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index d1f3f00..de41b06 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -55,6 +55,14 @@ struct SysBusDevice { } mmio[QDEV_MAX_MMIO]; int num_pio; pio_addr_t pio[QDEV_MAX_PIO]; + + /* + * Sometimes a SysBusDevice has neither MMIO nor PIO resources, yet it + * would like to distinguish itself, in OpenFirmware device paths, from + * other instances of the same class on the same sysbus. For that end we + * expose this property. + */ + char *explicit_ofw_unit_address; }; typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque); diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 0ebb4e2..6e9af1c 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -289,6 +289,10 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) if (s->num_pio) { return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); } + if (s->explicit_ofw_unit_address) { + return g_strdup_printf("%s@%s", qdev_fw_name(dev), + s->explicit_ofw_unit_address); + } return g_strdup(qdev_fw_name(dev)); } @@ -303,11 +307,18 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev) return get_system_memory(); } +static Property sysbus_device_properties[] = { + DEFINE_PROP_STRING("explicit_ofw_unit_address", SysBusDevice, + explicit_ofw_unit_address), + DEFINE_PROP_END_OF_LIST() +}; + static void sysbus_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k->init = sysbus_device_init; k->bus_type = TYPE_SYSTEM_BUS; + k->props = sysbus_device_properties; } static const TypeInfo sysbus_device_type_info = {