* [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements
@ 2017-09-09 15:05 Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code() Greg Kurz
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Greg Kurz @ 2017-09-09 15:05 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
Before resuming the huge work on PHB hotplug, here are some patches
that maybe worth to apply.
Patches 1 to 3 are basic improvements.
Patch 4 and 5 may be a bit controversial. Everywhere in the spapr
code where we build an FDT portion, libfdt failures cause QEMU to
exit, even on hotplug paths. Only spapr_pci doesn't do that and
propagates the error instead. My understanding is that a failure
when building the FDT is likely to happen because of a bug in QEMU.
Hence the choice to convert spapr_pci to do like the others. We may
even consider changing _FDT() to abort() instead of exit().
Alternatively, if libfdt failures shouldn't be necessarily fatal,
especially on post-realize paths, then we should probably introduce
an _FDT_ERR() helper to propagate errors. And use it in may places
where we currently terminate QEMU: memory hotplug, CPU hotplug, CAS,
machine reset...
--
Greg
---
Greg Kurz (5):
spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code()
spapr_pci: drop useless check in spapr_populate_pci_child_dt()
spapr_pci: use g_strdup_printf()
spapr_pci: use the common _FDT() helper
spapr_pci: handle FDT creation errors with _FDT()
hw/ppc/spapr_pci.c | 69 ++++++++++++++++------------------------------------
1 file changed, 21 insertions(+), 48 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code()
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
@ 2017-09-09 15:06 ` Greg Kurz
2017-09-10 16:56 ` Philippe Mathieu-Daudé
2017-09-09 15:06 ` [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt() Greg Kurz
` (5 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Greg Kurz @ 2017-09-09 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
g_strdup_printf() either returns a non-null pointer, either aborts
if it failed to allocate memory.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index d7880f257aa1..ef982f2ef370 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -766,7 +766,7 @@ static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
/* Construct the path of the file that will give us the DT location */
path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);
g_free(host);
- if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
+ if (!g_file_get_contents(path, &buf, NULL, NULL)) {
goto err_out;
}
g_free(path);
@@ -774,7 +774,7 @@ static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
/* Construct and read from host device tree the loc-code */
path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);
g_free(buf);
- if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
+ if (!g_file_get_contents(path, &buf, NULL, NULL)) {
goto err_out;
}
return buf;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt()
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code() Greg Kurz
@ 2017-09-09 15:06 ` Greg Kurz
2017-09-10 16:57 ` Philippe Mathieu-Daudé
2017-09-09 15:06 ` [Qemu-devel] [PATCH 3/5] spapr_pci: use g_strdup_printf() Greg Kurz
` (4 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Greg Kurz @ 2017-09-09 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
spapr_phb_get_loc_code() either returns a non-null pointer, either
aborts if g_strdup_printf() failed to allocate memory.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_pci.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index ef982f2ef370..cd8efb181223 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1282,12 +1282,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
pci_find_device_name((ccode >> 16) & 0xff,
(ccode >> 8) & 0xff,
ccode & 0xff)));
- buf = spapr_phb_get_loc_code(sphb, dev);
- if (!buf) {
- error_report("Failed setting the ibm,loc-code");
- return -1;
- }
+ buf = spapr_phb_get_loc_code(sphb, dev);
err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf);
g_free(buf);
if (err < 0) {
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 3/5] spapr_pci: use g_strdup_printf()
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code() Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt() Greg Kurz
@ 2017-09-09 15:06 ` Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 4/5] spapr_pci: use the common _FDT() helper Greg Kurz
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2017-09-09 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
Building strings with g_strdup_printf() instead of snprintf() is
a QEMU common practice.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_pci.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index cd8efb181223..6da73fe6bc29 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -61,8 +61,6 @@
#define RTAS_TYPE_MSI 1
#define RTAS_TYPE_MSIX 2
-#define FDT_NAME_MAX 128
-
#define _FDT(exp) \
do { \
int ret = (exp); \
@@ -1194,7 +1192,7 @@ static const char *pci_find_device_name(uint8_t class, uint8_t subclass,
return name;
}
-static void pci_get_node_name(char *nodename, int len, PCIDevice *dev)
+static gchar *pci_get_node_name(PCIDevice *dev)
{
int slot = PCI_SLOT(dev->devfn);
int func = PCI_FUNC(dev->devfn);
@@ -1205,9 +1203,9 @@ static void pci_get_node_name(char *nodename, int len, PCIDevice *dev)
ccode & 0xff);
if (func != 0) {
- snprintf(nodename, len, "%s@%x,%x", name, slot, func);
+ return g_strdup_printf("%s@%x,%x", name, slot, func);
} else {
- snprintf(nodename, len, "%s@%x", name, slot);
+ return g_strdup_printf("%s@%x", name, slot);
}
}
@@ -1325,10 +1323,12 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
void *fdt, int node_offset)
{
int offset, ret;
- char nodename[FDT_NAME_MAX];
+ gchar *nodename;
- pci_get_node_name(nodename, FDT_NAME_MAX, dev);
+ nodename = pci_get_node_name(dev);
offset = fdt_add_subnode(fdt, node_offset, nodename);
+ g_free(nodename);
+
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
g_assert(!ret);
@@ -2072,7 +2072,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
void *fdt)
{
int bus_off, i, j, ret;
- char nodename[FDT_NAME_MAX];
+ gchar *nodename;
uint32_t bus_range[] = { cpu_to_be32(0), cpu_to_be32(0xff) };
struct {
uint32_t hi;
@@ -2121,8 +2121,9 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
sPAPRFDT s_fdt;
/* Start populating the FDT */
- snprintf(nodename, FDT_NAME_MAX, "pci@%" PRIx64, phb->buid);
+ nodename = g_strdup_printf("pci@%" PRIx64, phb->buid);
bus_off = fdt_add_subnode(fdt, 0, nodename);
+ g_free(nodename);
if (bus_off < 0) {
return bus_off;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 4/5] spapr_pci: use the common _FDT() helper
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
` (2 preceding siblings ...)
2017-09-09 15:06 ` [Qemu-devel] [PATCH 3/5] spapr_pci: use g_strdup_printf() Greg Kurz
@ 2017-09-09 15:06 ` Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 5/5] spapr_pci: handle FDT creation errors with _FDT() Greg Kurz
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2017-09-09 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
All other users in hw/ppc already consider an error when building
the FDT to be fatal, even on hotplug paths. There's no valid reason
for spapr_pci to behave differently. So let's used the common _FDT()
helper which terminates QEMU when libfdt fails.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_pci.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 6da73fe6bc29..abb9f05e7b75 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -40,7 +40,7 @@
#include "trace.h"
#include "qemu/error-report.h"
#include "qapi/qmp/qerror.h"
-
+#include "hw/ppc/fdt.h"
#include "hw/pci/pci_bridge.h"
#include "hw/pci/pci_bus.h"
#include "hw/pci/pci_ids.h"
@@ -61,14 +61,6 @@
#define RTAS_TYPE_MSI 1
#define RTAS_TYPE_MSIX 2
-#define _FDT(exp) \
- do { \
- int ret = (exp); \
- if (ret < 0) { \
- return ret; \
- } \
- } while (0)
-
sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid)
{
sPAPRPHBState *sphb;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 5/5] spapr_pci: handle FDT creation errors with _FDT()
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
` (3 preceding siblings ...)
2017-09-09 15:06 ` [Qemu-devel] [PATCH 4/5] spapr_pci: use the common _FDT() helper Greg Kurz
@ 2017-09-09 15:06 ` Greg Kurz
2017-09-10 1:40 ` [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements David Gibson
2017-09-10 7:12 ` David Gibson
6 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2017-09-09 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
libfdt failures when creating the FDT should cause QEMU to terminate.
Let's use the _FDT() macro which does just that instead of propagating
the error to the caller. spapr_populate_pci_child_dt() no longer needs
to return a value in this case.
Note that, on the way, this get rids of the following nonsensical lines:
g_assert(!ret);
if (ret) {
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_pci.c | 30 +++++++-----------------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index abb9f05e7b75..75cd9392233e 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1204,12 +1204,12 @@ static gchar *pci_get_node_name(PCIDevice *dev)
static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb,
PCIDevice *pdev);
-static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
+static void spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
sPAPRPHBState *sphb)
{
ResourceProps rp;
bool is_bridge = false;
- int pci_status, err;
+ int pci_status;
char *buf = NULL;
uint32_t drc_index = spapr_phb_get_pci_drc_index(sphb, dev);
uint32_t ccode = pci_default_read_config(dev, PCI_CLASS_PROG, 3);
@@ -1274,11 +1274,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
ccode & 0xff)));
buf = spapr_phb_get_loc_code(sphb, dev);
- err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf);
+ _FDT(fdt_setprop_string(fdt, offset, "ibm,loc-code", buf));
g_free(buf);
- if (err < 0) {
- return err;
- }
if (drc_index) {
_FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index));
@@ -1306,27 +1303,21 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
if (sphb->pcie_ecs && pci_is_express(dev)) {
_FDT(fdt_setprop_cell(fdt, offset, "ibm,pci-config-space-type", 0x1));
}
-
- return 0;
}
/* create OF node for pci device and required OF DT properties */
static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
void *fdt, int node_offset)
{
- int offset, ret;
+ int offset;
gchar *nodename;
nodename = pci_get_node_name(dev);
- offset = fdt_add_subnode(fdt, node_offset, nodename);
+ _FDT(offset = fdt_add_subnode(fdt, node_offset, nodename));
g_free(nodename);
- ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
+ spapr_populate_pci_child_dt(dev, fdt, offset, phb);
- g_assert(!ret);
- if (ret) {
- return 0;
- }
return offset;
}
@@ -1416,10 +1407,6 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
fdt = create_device_tree(&fdt_size);
fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0);
- if (!fdt_start_offset) {
- error_setg(&local_err, "Failed to create pci child device tree node");
- goto out;
- }
spapr_drc_attach(drc, DEVICE(pdev), fdt, fdt_start_offset, &local_err);
if (local_err) {
@@ -2114,11 +2101,8 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
/* Start populating the FDT */
nodename = g_strdup_printf("pci@%" PRIx64, phb->buid);
- bus_off = fdt_add_subnode(fdt, 0, nodename);
+ _FDT(bus_off = fdt_add_subnode(fdt, 0, nodename));
g_free(nodename);
- if (bus_off < 0) {
- return bus_off;
- }
/* Write PHB properties */
_FDT(fdt_setprop_string(fdt, bus_off, "device_type", "pci"));
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
` (4 preceding siblings ...)
2017-09-09 15:06 ` [Qemu-devel] [PATCH 5/5] spapr_pci: handle FDT creation errors with _FDT() Greg Kurz
@ 2017-09-10 1:40 ` David Gibson
2017-09-10 7:12 ` David Gibson
6 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2017-09-10 1:40 UTC (permalink / raw)
To: Greg Kurz; +Cc: qemu-devel, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]
On Sat, Sep 09, 2017 at 05:05:46PM +0200, Greg Kurz wrote:
> Before resuming the huge work on PHB hotplug, here are some patches
> that maybe worth to apply.
>
> Patches 1 to 3 are basic improvements.
I've applied these to ppc-for-2.11.
> Patch 4 and 5 may be a bit controversial. Everywhere in the spapr
> code where we build an FDT portion, libfdt failures cause QEMU to
> exit, even on hotplug paths. Only spapr_pci doesn't do that and
> propagates the error instead. My understanding is that a failure
> when building the FDT is likely to happen because of a bug in QEMU.
Still looking at these.
>
> Hence the choice to convert spapr_pci to do like the others. We may
> even consider changing _FDT() to abort() instead of exit().
>
> Alternatively, if libfdt failures shouldn't be necessarily fatal,
> especially on post-realize paths, then we should probably introduce
> an _FDT_ERR() helper to propagate errors. And use it in may places
> where we currently terminate QEMU: memory hotplug, CPU hotplug, CAS,
> machine reset...
>
--
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: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
` (5 preceding siblings ...)
2017-09-10 1:40 ` [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements David Gibson
@ 2017-09-10 7:12 ` David Gibson
6 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2017-09-10 7:12 UTC (permalink / raw)
To: Greg Kurz; +Cc: qemu-devel, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]
On Sat, Sep 09, 2017 at 05:05:46PM +0200, Greg Kurz wrote:
> Before resuming the huge work on PHB hotplug, here are some patches
> that maybe worth to apply.
>
> Patches 1 to 3 are basic improvements.
>
> Patch 4 and 5 may be a bit controversial. Everywhere in the spapr
> code where we build an FDT portion, libfdt failures cause QEMU to
> exit, even on hotplug paths. Only spapr_pci doesn't do that and
> propagates the error instead. My understanding is that a failure
> when building the FDT is likely to happen because of a bug in QEMU.
>
> Hence the choice to convert spapr_pci to do like the others. We may
> even consider changing _FDT() to abort() instead of exit().
>
> Alternatively, if libfdt failures shouldn't be necessarily fatal,
> especially on post-realize paths, then we should probably introduce
> an _FDT_ERR() helper to propagate errors. And use it in may places
> where we currently terminate QEMU: memory hotplug, CPU hotplug, CAS,
> machine reset...
I've applied 4 & 5 as well now. If I get to it, I hope to make them
obsolete by replacing most of the fdt wrangling with a qemu internal
live tree representation, but in the meantime it's still a reasonable
cleanup.
--
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: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code()
2017-09-09 15:06 ` [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code() Greg Kurz
@ 2017-09-10 16:56 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-10 16:56 UTC (permalink / raw)
To: Greg Kurz, qemu-devel; +Cc: qemu-ppc, David Gibson
On 09/09/2017 12:06 PM, Greg Kurz wrote:
> g_strdup_printf() either returns a non-null pointer, either aborts
> if it failed to allocate memory.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/ppc/spapr_pci.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index d7880f257aa1..ef982f2ef370 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -766,7 +766,7 @@ static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
> /* Construct the path of the file that will give us the DT location */
> path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);
> g_free(host);
> - if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
> + if (!g_file_get_contents(path, &buf, NULL, NULL)) {
> goto err_out;
> }
> g_free(path);
> @@ -774,7 +774,7 @@ static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
> /* Construct and read from host device tree the loc-code */
> path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);
> g_free(buf);
> - if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
> + if (!g_file_get_contents(path, &buf, NULL, NULL)) {
> goto err_out;
> }
> return buf;
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt()
2017-09-09 15:06 ` [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt() Greg Kurz
@ 2017-09-10 16:57 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-10 16:57 UTC (permalink / raw)
To: Greg Kurz, qemu-devel; +Cc: qemu-ppc, David Gibson
On 09/09/2017 12:06 PM, Greg Kurz wrote:
> spapr_phb_get_loc_code() either returns a non-null pointer, either
> aborts if g_strdup_printf() failed to allocate memory.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/ppc/spapr_pci.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index ef982f2ef370..cd8efb181223 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1282,12 +1282,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
> pci_find_device_name((ccode >> 16) & 0xff,
> (ccode >> 8) & 0xff,
> ccode & 0xff)));
> - buf = spapr_phb_get_loc_code(sphb, dev);
> - if (!buf) {
> - error_report("Failed setting the ibm,loc-code");
> - return -1;
> - }
>
> + buf = spapr_phb_get_loc_code(sphb, dev);
> err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf);
> g_free(buf);
> if (err < 0) {
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-09-11 13:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-09 15:05 [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code() Greg Kurz
2017-09-10 16:56 ` Philippe Mathieu-Daudé
2017-09-09 15:06 ` [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt() Greg Kurz
2017-09-10 16:57 ` Philippe Mathieu-Daudé
2017-09-09 15:06 ` [Qemu-devel] [PATCH 3/5] spapr_pci: use g_strdup_printf() Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 4/5] spapr_pci: use the common _FDT() helper Greg Kurz
2017-09-09 15:06 ` [Qemu-devel] [PATCH 5/5] spapr_pci: handle FDT creation errors with _FDT() Greg Kurz
2017-09-10 1:40 ` [Qemu-devel] [PATCH 0/5] spapr_pci: various cleanups and improvements David Gibson
2017-09-10 7:12 ` David Gibson
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).