From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,
Andreas Faerber <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH v5 6/6] spapr: define interface to fix device pathname
Date: Fri, 21 Feb 2014 00:50:46 +1100 [thread overview]
Message-ID: <1392904246-15575-7-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1392904246-15575-1-git-send-email-aik@ozlabs.ru>
This defines an object with the interface to fix firmware pathnames
for devices which have @bootindex property.
This fixes SCSI disks device node names (which are wildcard nodes in
the device-tree), for spapr-vsci, virtio-scsi and usb-storage.
This fixes PHB name from "pci" to "pci@XXXX" where XXXX is a BUID as
there is no bus on top of sPAPRPHBState where PHB firmware name could
be fixed using the BusClass::get_fw_dev_path mechanism.
This stores the boot list in the /chosen/qemu,boot-list property of
the device tree. "\n" are replaced by spaces to support OF1275.
SLOF needs an update in order to support the boot list.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v5:
* addev virtio and usb handling
v2:
* added special handling for virtio-scsi and USB as they use different
LUN encoding in SLOF
---
hw/ppc/spapr.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 102 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0989ed6..79f6a5d 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -26,6 +26,7 @@
*/
#include "sysemu/sysemu.h"
#include "hw/hw.h"
+#include "hw/fw-path-provider.h"
#include "elf.h"
#include "net/net.h"
#include "sysemu/blockdev.h"
@@ -45,6 +46,8 @@
#include "hw/pci/msi.h"
#include "hw/pci/pci.h"
+#include "hw/scsi/scsi.h"
+#include "hw/virtio/virtio-scsi.h"
#include "exec/address-spaces.h"
#include "hw/usb.h"
@@ -81,6 +84,8 @@
#define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift))
+#define TYPE_SPAPR_MACHINE "machine-spapr"
+
sPAPREnvironment *spapr;
int spapr_allocate_irq(int hint, bool lsi)
@@ -597,7 +602,9 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
hwaddr rtas_addr,
hwaddr rtas_size)
{
- int ret;
+ int ret, i;
+ size_t cb = 0;
+ char *bootlist;
void *fdt;
sPAPRPHBState *phb;
@@ -639,6 +646,21 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
fprintf(stderr, "Couldn't finalize CPU device tree properties\n");
}
+ bootlist = get_boot_devices_list(&cb, true);
+ if (cb && bootlist) {
+ int offset = fdt_path_offset(fdt, "/chosen");
+ if (offset < 0) {
+ exit(1);
+ }
+ for (i = 0; i < cb; i++) {
+ if (bootlist[i] == '\n') {
+ bootlist[i] = ' ';
+ }
+
+ }
+ ret = fdt_setprop_string(fdt, offset, "qemu,boot-list", bootlist);
+ }
+
if (!spapr->has_graphics) {
spapr_populate_chosen_stdout(fdt, spapr->vio_bus);
}
@@ -1390,6 +1412,7 @@ static int spapr_kvm_type(const char *vm_type)
static QEMUMachine spapr_machine = {
.name = "pseries",
.desc = "pSeries Logical Partition (PAPR compliant)",
+ .class_name = TYPE_SPAPR_MACHINE,
.is_default = 1,
.init = ppc_spapr_init,
.reset = ppc_spapr_reset,
@@ -1406,3 +1429,81 @@ static void spapr_machine_init(void)
}
machine_init(spapr_machine_init);
+
+/*
+ * Implementation of an interface to adjust firmware patch
+ * for the bootindex property handling.
+ */
+static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
+ DeviceState *dev)
+{
+#define CAST(type, obj, name) \
+ ((type *)object_dynamic_cast(OBJECT(obj), (name)))
+ SCSIDevice *d = CAST(SCSIDevice, dev, TYPE_SCSI_DEVICE);
+ sPAPRPHBState *phb = CAST(sPAPRPHBState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE);
+
+ if (d) {
+ void *spapr = CAST(void, bus->parent, "spapr-vscsi");
+ VirtIOSCSI *virtio = CAST(VirtIOSCSI, bus->parent, TYPE_VIRTIO_SCSI);
+ USBDevice *usb = CAST(USBDevice, bus->parent, TYPE_USB_DEVICE);
+
+ if (spapr) {
+ /*
+ * Replace "channel@0/disk@0,0" with "disk@8000000000000000":
+ * We use SRP luns of the form 8000 | (bus << 8) | (id << 5) | lun
+ * in the top 16 bits of the 64-bit LUN
+ */
+ unsigned id = 0x8000 | (d->id << 8) | d->lun;
+ return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+ (uint64_t)id << 48);
+ } else if (virtio) {
+ /*
+ * We use SRP luns of the form 01000000 | (target << 8) | lun
+ * in the top 32 bits of the 64-bit LUN
+ */
+ unsigned id = 0x1000000 | (d->id << 8) | d->lun;
+ return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+ (uint64_t)id << 32);
+ } else if (usb) {
+ /*
+ * We use SRP luns of the form 01000000 | (usb-port << 16) | lun
+ * in the top 32 bits of the 64-bit LUN
+ */
+ unsigned usb_port = atoi(usb->port->path);
+ unsigned id = 0x1000000 | (usb_port << 16) | d->lun;
+ return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+ (uint64_t)id << 32);
+ }
+ }
+
+ if (phb) {
+ /* Replace "pci" with "pci@800000020000000" */
+ return g_strdup_printf("pci@%"PRIX64, phb->buid);
+ }
+
+ return NULL;
+}
+
+static void spapr_machine_class_init(ObjectClass *oc, void *data)
+{
+ FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
+
+ fwc->get_dev_path = spapr_get_fw_dev_path;
+}
+
+static const TypeInfo spapr_machine_info = {
+ .name = TYPE_SPAPR_MACHINE,
+ .parent = TYPE_OBJECT,
+ .class_init = spapr_machine_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_FW_PATH_PROVIDER },
+ { }
+ }
+};
+
+static void spapr_machine_register_types(void)
+{
+ type_register_static(&spapr_machine_info);
+}
+
+type_init(spapr_machine_register_types)
--
1.8.4.rc4
next prev parent reply other threads:[~2014-02-20 13:51 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 13:50 [Qemu-devel] [PATCH v5 0/6] spapr: bootindex support Alexey Kardashevskiy
2014-02-20 13:50 ` [Qemu-devel] [PATCH v5 1/6] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
2014-02-20 13:55 ` Paolo Bonzini
2014-02-20 14:03 ` Alexey Kardashevskiy
2014-02-20 14:05 ` Paolo Bonzini
2014-03-13 3:32 ` Alexey Kardashevskiy
2014-03-13 8:00 ` Paolo Bonzini
2014-02-20 13:50 ` [Qemu-devel] [PATCH v5 2/6] qdev: introduce FWPathProvider interface Alexey Kardashevskiy
2014-03-12 18:07 ` Andreas Färber
2014-03-12 18:15 ` Paolo Bonzini
2014-03-12 23:02 ` Alexey Kardashevskiy
2014-03-12 23:38 ` Andreas Färber
2014-03-13 1:03 ` Alexey Kardashevskiy
2014-03-13 3:40 ` Alexey Kardashevskiy
2014-02-20 13:50 ` [Qemu-devel] [PATCH v5 3/6] vl: allow customizing the class of /machine Alexey Kardashevskiy
2014-02-20 13:58 ` Paolo Bonzini
2014-02-27 10:34 ` Andreas Färber
2014-02-27 10:41 ` Paolo Bonzini
2014-02-27 14:39 ` Marcel Apfelbaum
2014-02-27 14:59 ` Paolo Bonzini
2014-02-27 15:04 ` Marcel Apfelbaum
2014-02-28 15:03 ` Alexey Kardashevskiy
2014-02-28 15:05 ` Paolo Bonzini
2014-02-28 15:08 ` Alexey Kardashevskiy
2014-02-28 15:57 ` Andreas Färber
2014-02-28 16:35 ` Paolo Bonzini
2014-03-03 10:04 ` Alexey Kardashevskiy
2014-02-21 3:04 ` Alexey Kardashevskiy
2014-02-21 10:30 ` Paolo Bonzini
2014-02-27 2:35 ` Alexey Kardashevskiy
2014-02-27 7:44 ` Markus Armbruster
2014-02-27 11:47 ` Alexey Kardashevskiy
2014-02-27 13:38 ` Markus Armbruster
2014-02-20 13:50 ` [Qemu-devel] [PATCH v5 4/6] spapr-llan: add to boot device list Alexey Kardashevskiy
2014-02-20 13:50 ` [Qemu-devel] [PATCH v5 5/6] spapr-vio: fix firmware names Alexey Kardashevskiy
2014-02-20 13:50 ` Alexey Kardashevskiy [this message]
2014-02-20 13:58 ` [Qemu-devel] [PATCH v5 0/6] spapr: bootindex support Paolo Bonzini
2014-02-20 14:05 ` Alexey Kardashevskiy
2014-02-20 14:06 ` Paolo Bonzini
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=1392904246-15575-7-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=pbonzini@redhat.com \
--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).