All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups
@ 2016-08-02 17:37 Cédric Le Goater
  2016-08-02 17:38 ` [Qemu-devel] [PATCH 1/2] hw/ppc: use error_report instead of fprintf Cédric Le Goater
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Cédric Le Goater @ 2016-08-02 17:37 UTC (permalink / raw)
  To: qemu-ppc; +Cc: David Gibson, qemu-devel, Cédric Le Goater

Hello,

Here are a couple of enhancements for sPAPR but PowerNV should use
them also.

Thanks,

C. 

Cédric Le Goater (2):
  hw/ppc: use error_report instead of fprintf
  hw/ppc: add a ppc_create_page_sizes_prop() helper routine

 hw/ppc/Makefile.objs |  2 +-
 hw/ppc/fdt.c         | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/spapr.c       | 48 +++++++-----------------------------------------
 hw/ppc/spapr_drc.c   |  8 ++++----
 hw/ppc/spapr_iommu.c |  4 ++--
 hw/ppc/spapr_rtas.c  | 13 +++++++------
 hw/ppc/spapr_vio.c   |  3 ++-
 include/hw/ppc/fdt.h | 13 ++++++++++---
 8 files changed, 82 insertions(+), 58 deletions(-)
 create mode 100644 hw/ppc/fdt.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 1/2] hw/ppc: use error_report instead of fprintf
  2016-08-02 17:37 [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups Cédric Le Goater
@ 2016-08-02 17:38 ` Cédric Le Goater
  2016-08-02 17:38 ` [Qemu-devel] [PATCH 2/2] hw/ppc: add a ppc_create_page_sizes_prop() helper routine Cédric Le Goater
  2016-08-02 23:10 ` [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups David Gibson
  2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2016-08-02 17:38 UTC (permalink / raw)
  To: qemu-ppc; +Cc: David Gibson, qemu-devel, Cédric Le Goater

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 Changes since v1:

 - fixed _FDT() macro

 hw/ppc/spapr.c       |   12 ++++++------
 hw/ppc/spapr_drc.c   |    8 ++++----
 hw/ppc/spapr_iommu.c |    4 ++--
 hw/ppc/spapr_rtas.c  |   13 +++++++------
 hw/ppc/spapr_vio.c   |    3 ++-
 include/hw/ppc/fdt.h |    8 +++++---
 6 files changed, 26 insertions(+), 22 deletions(-)

Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
@@ -647,13 +647,13 @@ static void spapr_populate_cpu_dt(CPUSta
         _FDT((fdt_setprop_cell(fdt, offset, "d-cache-size",
                                pcc->l1_dcache_size)));
     } else {
-        fprintf(stderr, "Warning: Unknown L1 dcache size for cpu\n");
+        error_report("Warning: Unknown L1 dcache size for cpu");
     }
     if (pcc->l1_icache_size) {
         _FDT((fdt_setprop_cell(fdt, offset, "i-cache-size",
                                pcc->l1_icache_size)));
     } else {
-        fprintf(stderr, "Warning: Unknown L1 icache size for cpu\n");
+        error_report("Warning: Unknown L1 icache size for cpu");
     }
 
     _FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq)));
@@ -944,20 +944,20 @@ static void spapr_finalize_fdt(sPAPRMach
 
     ret = spapr_populate_memory(spapr, fdt);
     if (ret < 0) {
-        fprintf(stderr, "couldn't setup memory nodes in fdt\n");
+        error_report("couldn't setup memory nodes in fdt");
         exit(1);
     }
 
     ret = spapr_populate_vdevice(spapr->vio_bus, fdt);
     if (ret < 0) {
-        fprintf(stderr, "couldn't setup vio devices in fdt\n");
+        error_report("couldn't setup vio devices in fdt");
         exit(1);
     }
 
     if (object_resolve_path_type("", TYPE_SPAPR_RNG, NULL)) {
         ret = spapr_rng_populate_dt(fdt);
         if (ret < 0) {
-            fprintf(stderr, "could not set up rng device in the fdt\n");
+            error_report("could not set up rng device in the fdt");
             exit(1);
         }
     }
@@ -973,7 +973,7 @@ static void spapr_finalize_fdt(sPAPRMach
     /* RTAS */
     ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);
     if (ret < 0) {
-        fprintf(stderr, "Couldn't set up RTAS device tree properties\n");
+        error_report("Couldn't set up RTAS device tree properties");
     }
 
     /* cpus */
Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr_drc.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr_drc.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr_drc.c
@@ -816,7 +816,7 @@ int spapr_drc_populate_dt(void *fdt, int
                       drc_indexes->data,
                       drc_indexes->len * sizeof(uint32_t));
     if (ret) {
-        fprintf(stderr, "Couldn't create ibm,drc-indexes property\n");
+        error_report("Couldn't create ibm,drc-indexes property");
         goto out;
     }
 
@@ -824,21 +824,21 @@ int spapr_drc_populate_dt(void *fdt, int
                       drc_power_domains->data,
                       drc_power_domains->len * sizeof(uint32_t));
     if (ret) {
-        fprintf(stderr, "Couldn't finalize ibm,drc-power-domains property\n");
+        error_report("Couldn't finalize ibm,drc-power-domains property");
         goto out;
     }
 
     ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-names",
                       drc_names->str, drc_names->len);
     if (ret) {
-        fprintf(stderr, "Couldn't finalize ibm,drc-names property\n");
+        error_report("Couldn't finalize ibm,drc-names property");
         goto out;
     }
 
     ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-types",
                       drc_types->str, drc_types->len);
     if (ret) {
-        fprintf(stderr, "Couldn't finalize ibm,drc-types property\n");
+        error_report("Couldn't finalize ibm,drc-types property");
         goto out;
     }
 
Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr_iommu.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr_iommu.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr_iommu.c
@@ -310,8 +310,8 @@ sPAPRTCETable *spapr_tce_new_table(Devic
     char tmp[32];
 
     if (spapr_tce_find_by_liobn(liobn)) {
-        fprintf(stderr, "Attempted to create TCE table with duplicate"
-                " LIOBN 0x%x\n", liobn);
+        error_report("Attempted to create TCE table with duplicate"
+                " LIOBN 0x%x", liobn);
         return NULL;
     }
 
Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr_rtas.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr_rtas.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr_rtas.c
@@ -27,6 +27,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "qemu/log.h"
+#include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/char.h"
 #include "hw/qdev.h"
@@ -716,7 +717,7 @@ int spapr_rtas_device_tree_setup(void *f
 
     ret = fdt_add_mem_rsv(fdt, rtas_addr, rtas_size);
     if (ret < 0) {
-        fprintf(stderr, "Couldn't add RTAS reserve entry: %s\n",
+        error_report("Couldn't add RTAS reserve entry: %s",
                 fdt_strerror(ret));
         return ret;
     }
@@ -724,7 +725,7 @@ int spapr_rtas_device_tree_setup(void *f
     ret = qemu_fdt_setprop_cell(fdt, "/rtas", "linux,rtas-base",
                                 rtas_addr);
     if (ret < 0) {
-        fprintf(stderr, "Couldn't add linux,rtas-base property: %s\n",
+        error_report("Couldn't add linux,rtas-base property: %s",
                 fdt_strerror(ret));
         return ret;
     }
@@ -732,7 +733,7 @@ int spapr_rtas_device_tree_setup(void *f
     ret = qemu_fdt_setprop_cell(fdt, "/rtas", "linux,rtas-entry",
                                 rtas_addr);
     if (ret < 0) {
-        fprintf(stderr, "Couldn't add linux,rtas-entry property: %s\n",
+        error_report("Couldn't add linux,rtas-entry property: %s",
                 fdt_strerror(ret));
         return ret;
     }
@@ -740,7 +741,7 @@ int spapr_rtas_device_tree_setup(void *f
     ret = qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size",
                                 rtas_size);
     if (ret < 0) {
-        fprintf(stderr, "Couldn't add rtas-size property: %s\n",
+        error_report("Couldn't add rtas-size property: %s",
                 fdt_strerror(ret));
         return ret;
     }
@@ -755,7 +756,7 @@ int spapr_rtas_device_tree_setup(void *f
         ret = qemu_fdt_setprop_cell(fdt, "/rtas", call->name,
                                     i + RTAS_TOKEN_BASE);
         if (ret < 0) {
-            fprintf(stderr, "Couldn't add rtas token for %s: %s\n",
+            error_report("Couldn't add rtas token for %s: %s",
                     call->name, fdt_strerror(ret));
             return ret;
         }
@@ -770,7 +771,7 @@ int spapr_rtas_device_tree_setup(void *f
     ret = qemu_fdt_setprop(fdt, "/rtas", "ibm,lrdr-capacity", lrdr_capacity,
                      sizeof(lrdr_capacity));
     if (ret < 0) {
-        fprintf(stderr, "Couldn't add ibm,lrdr-capacity rtas property\n");
+        error_report("Couldn't add ibm,lrdr-capacity rtas property");
         return ret;
     }
 
Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr_vio.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr_vio.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr_vio.c
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "qemu/log.h"
@@ -276,7 +277,7 @@ int spapr_vio_send_crq(VIOsPAPRDevice *d
     uint8_t byte;
 
     if (!dev->crq.qsize) {
-        fprintf(stderr, "spapr_vio_send_creq on uninitialized queue\n");
+        error_report("spapr_vio_send_creq on uninitialized queue");
         return -1;
     }
 
Index: qemu-dgibson-for-2.8.git/include/hw/ppc/fdt.h
===================================================================
--- qemu-dgibson-for-2.8.git.orig/include/hw/ppc/fdt.h
+++ qemu-dgibson-for-2.8.git/include/hw/ppc/fdt.h
@@ -10,11 +10,13 @@
 #ifndef PPC_FDT_H
 #define PPC_FDT_H
 
-#define _FDT(exp)                               \
-    do { \
+#include "qemu/error-report.h"
+
+#define _FDT(exp)                                                  \
+    do {                                                           \
         int ret = (exp);                                           \
         if (ret < 0) {                                             \
-            fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
+            error_report("error creating device tree: %s: %s",   \
                     #exp, fdt_strerror(ret));                      \
             exit(1);                                               \
         }                                                          \

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 2/2] hw/ppc: add a ppc_create_page_sizes_prop() helper routine
  2016-08-02 17:37 [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups Cédric Le Goater
  2016-08-02 17:38 ` [Qemu-devel] [PATCH 1/2] hw/ppc: use error_report instead of fprintf Cédric Le Goater
@ 2016-08-02 17:38 ` Cédric Le Goater
  2016-08-02 23:10 ` [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups David Gibson
  2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2016-08-02 17:38 UTC (permalink / raw)
  To: qemu-ppc; +Cc: David Gibson, qemu-devel, Cédric Le Goater

The exact same routine will be used in PowerNV.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/Makefile.objs |  2 +-
 hw/ppc/fdt.c         | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/spapr.c       | 36 +-----------------------------------
 include/hw/ppc/fdt.h |  5 +++++
 4 files changed, 56 insertions(+), 36 deletions(-)
 create mode 100644 hw/ppc/fdt.c

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 91a3420f473a..99a0d4e581bf 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -1,5 +1,5 @@
 # shared objects
-obj-y += ppc.o ppc_booke.o
+obj-y += ppc.o ppc_booke.o fdt.o
 # IBM pSeries (sPAPR)
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
diff --git a/hw/ppc/fdt.c b/hw/ppc/fdt.c
new file mode 100644
index 000000000000..e67d60d03c78
--- /dev/null
+++ b/hw/ppc/fdt.c
@@ -0,0 +1,49 @@
+/*
+ * QEMU PowerPC helper routines for the device tree.
+ *
+ * Copyright (C) 2016 IBM Corp.
+ *
+ * This code is licensed under the GPL version 2 or later. See the
+ * COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "target-ppc/cpu.h"
+
+#include "hw/ppc/fdt.h"
+
+#if defined(TARGET_PPC64)
+size_t ppc_create_page_sizes_prop(CPUPPCState *env, uint32_t *prop,
+                                     size_t maxsize)
+{
+    size_t maxcells = maxsize / sizeof(uint32_t);
+    int i, j, count;
+    uint32_t *p = prop;
+
+    for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {
+        struct ppc_one_seg_page_size *sps = &env->sps.sps[i];
+
+        if (!sps->page_shift) {
+            break;
+        }
+        for (count = 0; count < PPC_PAGE_SIZES_MAX_SZ; count++) {
+            if (sps->enc[count].page_shift == 0) {
+                break;
+            }
+        }
+        if ((p - prop) >= (maxcells - 3 - count * 2)) {
+            break;
+        }
+        *(p++) = cpu_to_be32(sps->page_shift);
+        *(p++) = cpu_to_be32(sps->slb_enc);
+        *(p++) = cpu_to_be32(count);
+        for (j = 0; j < count; j++) {
+            *(p++) = cpu_to_be32(sps->enc[j].page_shift);
+            *(p++) = cpu_to_be32(sps->enc[j].pte_enc);
+        }
+    }
+
+    return (p - prop) * sizeof(uint32_t);
+}
+#endif
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ebf0b697f8d7..053b5817a814 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -250,40 +250,6 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
     return ret;
 }
 
-
-static size_t create_page_sizes_prop(CPUPPCState *env, uint32_t *prop,
-                                     size_t maxsize)
-{
-    size_t maxcells = maxsize / sizeof(uint32_t);
-    int i, j, count;
-    uint32_t *p = prop;
-
-    for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {
-        struct ppc_one_seg_page_size *sps = &env->sps.sps[i];
-
-        if (!sps->page_shift) {
-            break;
-        }
-        for (count = 0; count < PPC_PAGE_SIZES_MAX_SZ; count++) {
-            if (sps->enc[count].page_shift == 0) {
-                break;
-            }
-        }
-        if ((p - prop) >= (maxcells - 3 - count * 2)) {
-            break;
-        }
-        *(p++) = cpu_to_be32(sps->page_shift);
-        *(p++) = cpu_to_be32(sps->slb_enc);
-        *(p++) = cpu_to_be32(count);
-        for (j = 0; j < count; j++) {
-            *(p++) = cpu_to_be32(sps->enc[j].page_shift);
-            *(p++) = cpu_to_be32(sps->enc[j].pte_enc);
-        }
-    }
-
-    return (p - prop) * sizeof(uint32_t);
-}
-
 static hwaddr spapr_node0_size(void)
 {
     MachineState *machine = MACHINE(qdev_get_machine());
@@ -689,7 +655,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
         _FDT((fdt_setprop_cell(fdt, offset, "ibm,dfp", 1)));
     }
 
-    page_sizes_prop_size = create_page_sizes_prop(env, page_sizes_prop,
+    page_sizes_prop_size = ppc_create_page_sizes_prop(env, page_sizes_prop,
                                                   sizeof(page_sizes_prop));
     if (page_sizes_prop_size) {
         _FDT((fdt_setprop(fdt, offset, "ibm,segment-page-sizes",
diff --git a/include/hw/ppc/fdt.h b/include/hw/ppc/fdt.h
index c838d5a13bc9..3f63d521f2ff 100644
--- a/include/hw/ppc/fdt.h
+++ b/include/hw/ppc/fdt.h
@@ -12,6 +12,8 @@
 
 #include "qemu/error-report.h"
 
+typedef struct CPUPPCState CPUPPCState;
+
 #define _FDT(exp)                                                  \
     do {                                                           \
         int ret = (exp);                                           \
@@ -22,4 +24,7 @@
         }                                                          \
     } while (0)
 
+size_t ppc_create_page_sizes_prop(CPUPPCState *env, uint32_t *prop,
+                                  size_t maxsize);
+
 #endif /* PPC_FDT_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups
  2016-08-02 17:37 [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups Cédric Le Goater
  2016-08-02 17:38 ` [Qemu-devel] [PATCH 1/2] hw/ppc: use error_report instead of fprintf Cédric Le Goater
  2016-08-02 17:38 ` [Qemu-devel] [PATCH 2/2] hw/ppc: add a ppc_create_page_sizes_prop() helper routine Cédric Le Goater
@ 2016-08-02 23:10 ` David Gibson
  2 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2016-08-02 23:10 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

On Tue, Aug 02, 2016 at 07:37:59PM +0200, Cédric Le Goater wrote:
> Hello,
> 
> Here are a couple of enhancements for sPAPR but PowerNV should use
> them also.

Applied to ppc-for-2.8, thanks.

> 
> Thanks,
> 
> C. 
> 
> Cédric Le Goater (2):
>   hw/ppc: use error_report instead of fprintf
>   hw/ppc: add a ppc_create_page_sizes_prop() helper routine
> 
>  hw/ppc/Makefile.objs |  2 +-
>  hw/ppc/fdt.c         | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/ppc/spapr.c       | 48 +++++++-----------------------------------------
>  hw/ppc/spapr_drc.c   |  8 ++++----
>  hw/ppc/spapr_iommu.c |  4 ++--
>  hw/ppc/spapr_rtas.c  | 13 +++++++------
>  hw/ppc/spapr_vio.c   |  3 ++-
>  include/hw/ppc/fdt.h | 13 ++++++++++---
>  8 files changed, 82 insertions(+), 58 deletions(-)
>  create mode 100644 hw/ppc/fdt.c
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-02 23:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-02 17:37 [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups Cédric Le Goater
2016-08-02 17:38 ` [Qemu-devel] [PATCH 1/2] hw/ppc: use error_report instead of fprintf Cédric Le Goater
2016-08-02 17:38 ` [Qemu-devel] [PATCH 2/2] hw/ppc: add a ppc_create_page_sizes_prop() helper routine Cédric Le Goater
2016-08-02 23:10 ` [Qemu-devel] [PATCH 0/2] hw/ppc: fdt cleanups David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.