qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	qemu-ppc@nongnu.org, Paul Mackerras <paulus@samba.org>,
	Alexander Graf <agraf@suse.de>,
	Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v2] spapr: define get_fw_dev_path() callback
Date: Tue, 26 Nov 2013 15:05:44 +1100	[thread overview]
Message-ID: <1385438744-30505-1-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1385364460-24332-6-git-send-email-aik@ozlabs.ru>

This introduces a get_fw_dev_path() callback.

This fixes SCSI disks device node names (which are wildcard nodes in
the device-tree).

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. SLOF needs an update in order to support the boot list.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* \n replaced with space as this is what SLOF expects there
* qemu,bootlist renamed to qemu,boot-list
---
 hw/ppc/spapr.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 7e53a5f..fe02f23 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -45,6 +45,7 @@
 #include "hw/pci/msi.h"
 
 #include "hw/pci/pci.h"
+#include "hw/scsi/scsi.h"
 
 #include "exec/address-spaces.h"
 #include "hw/usb.h"
@@ -587,9 +588,11 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
                                hwaddr rtas_addr,
                                hwaddr rtas_size)
 {
-    int ret;
+    int ret, i;
     void *fdt;
     sPAPRPHBState *phb;
+    size_t cb = 0;
+    char *bootlist;
 
     fdt = g_malloc(FDT_MAX_SIZE);
 
@@ -633,6 +636,21 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
         spapr_populate_chosen_stdout(fdt, spapr->vio_bus);
     }
 
+    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);
+    }
+
     _FDT((fdt_pack(fdt)));
 
     if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
@@ -1357,6 +1375,34 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
     assert(spapr->fdt_skel != NULL);
 }
 
+#define CAST(type, obj, name) \
+    ((type *)object_dynamic_cast(OBJECT(obj), (name)))
+
+static char *spapr_get_fw_dev_path(BusState *bus, DeviceState *dev)
+{
+    SCSIDevice *d = CAST(SCSIDevice,  dev, TYPE_SCSI_DEVICE);
+    sPAPRPHBState *phb = CAST(sPAPRPHBState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE);
+
+    if (d) {
+        /*
+         * 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->channel << 8) | (d->id << 5) | d->lun;
+
+        return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
+                               (uint64_t)id << 48);
+    }
+
+    if (phb) {
+        /* Replace "pci" with "pci@800000020000000" */
+        return g_strdup_printf("pci@%"PRIX64, phb->buid);
+    }
+
+    return NULL;
+}
+
 static QEMUMachine spapr_machine = {
     .name = "pseries",
     .desc = "pSeries Logical Partition (PAPR compliant)",
@@ -1367,6 +1413,7 @@ static QEMUMachine spapr_machine = {
     .max_cpus = MAX_CPUS,
     .no_parallel = 1,
     .default_boot_order = NULL,
+    .get_fw_dev_path = spapr_get_fw_dev_path
 };
 
 static void spapr_machine_init(void)
-- 
1.8.4.rc4

      reply	other threads:[~2013-11-26  4:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25  7:27 [Qemu-devel] [RFC PATCH 0/5] spapr: support bootindex Alexey Kardashevskiy
2013-11-25  7:27 ` [Qemu-devel] [PATCH 1/5] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
2013-11-25  7:27 ` [Qemu-devel] [PATCH 2/5] machine: introduce get_fw_dev_path() callback Alexey Kardashevskiy
2013-11-26  4:55   ` Alexey Kardashevskiy
2013-12-03  3:52     ` Alexey Kardashevskiy
2013-12-03  9:11       ` Markus Armbruster
2013-12-03  9:32         ` Alexey Kardashevskiy
2013-12-03  9:41           ` Paolo Bonzini
2013-12-03 13:41       ` Andreas Färber
2013-12-03  9:37   ` Paolo Bonzini
2013-12-03 13:44     ` Andreas Färber
2013-12-03 14:00       ` Paolo Bonzini
2013-12-03 14:35         ` Andreas Färber
2013-12-03 14:58           ` Paolo Bonzini
2013-12-11  5:20             ` Alexey Kardashevskiy
2013-12-11  7:47               ` Paolo Bonzini
2013-12-11  7:59                 ` Alexey Kardashevskiy
2013-12-11  8:38                   ` Alexey Kardashevskiy
2013-12-10  7:34         ` Alexey Kardashevskiy
2013-11-25  7:27 ` [Qemu-devel] [PATCH 3/5] spapr-llan: add to boot device list Alexey Kardashevskiy
2013-11-25  7:27 ` [Qemu-devel] [PATCH 4/5] spapr-vio: fix firmware names Alexey Kardashevskiy
2013-11-25  7:27 ` [Qemu-devel] [PATCH 5/5] spapr: define get_fw_dev_path() callback Alexey Kardashevskiy
2013-11-26  4:05   ` Alexey Kardashevskiy [this message]

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=1385438744-30505-1-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=agraf@suse.de \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --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).