Skip to contentSkip to conversation

ppc: virtex_ml507: QEMU_OPTION_dtb support for this machine.

PATCH Superseded Efimov Vasily 5 participants 9 messages Aug 13, 2013 – Aug 14, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: virtex_ml507: QEMU_OPTION_dtb support for this machine.

---
 hw/ppc/virtex_ml507.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
hw/ppc/virtex_ml507.c +10 -3
index 08e77fb..a00f709 100644
@@ -141,11 +141,18 @@ static int xilinx_load_device_tree(hwaddr addr,
 {
     char *path;
     int fdt_size;
-    void *fdt;
+    void *fdt = 0;
     int r;
+    const char *dtb_filename;
 
-    /* Try the local "ppc.dtb" override.  */
-    fdt = load_device_tree("ppc.dtb", &fdt_size);
+    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    if (dtb_filename) {
+        fdt = load_device_tree(dtb_filename, &fdt_size);
+    }
+    if (!fdt) {
+        /* Try the local "ppc.dtb" override.  */
+        fdt = load_device_tree("ppc.dtb", &fdt_size);
+    }
     if (!fdt) {
         path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
         if (path) {
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 2 lines · Efimov Vasily

Please provide a patch description :).

Quoted 9 lines

---
hw/ppc/virtex_ml507.c | 13 ++++++++++---

1 file changed, 10 insertions(+), 3 deletions(-)
hw/ppc/virtex_ml507.c +0 -0
index 08e77fb..a00f709 100644

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 5 lines
hw/ppc/virtex_ml507.c +1 -1
@@ -141,11 +141,18 @@ static int xilinx_load_device_tree(hwaddr addr,
 {
    char *path;
    int fdt_size;
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 155

Quoted 13 lines
hw/ppc/virtex_ml507.c +9 -2
    int r;
+    const char *dtb_filename;
 
-    /* Try the local "ppc.dtb" override.  */
-    fdt = load_device_tree("ppc.dtb", &fdt_size);
+    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    if (dtb_filename) {
+        fdt = load_device_tree(dtb_filename, &fdt_size);
+    }
+    if (!fdt) {
+        /* Try the local "ppc.dtb" override.  */
+        fdt = load_device_tree("ppc.dtb", &fdt_size);
+    }

Could you please just remove the ppc.dtb override option? It's superfluous once we have proper -dtb support.

Edgar, any objections?

Also, you should abort if the user specified a dtb through -dtb and that file could not get loaded.

Alex

Quoted 6 lines
hw/ppc/virtex_ml507.c +0 -0
    if (!fdt) {
        path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
        if (path) {
Signature · 1 line
1.7.10.4
#2 lore raw
Quoted 39 lines · Alexander Graf
Quoted 2 lines · Efimov Vasily

Please provide a patch description :).

Quoted 9 lines

---
hw/ppc/virtex_ml507.c | 13 ++++++++++---

1 file changed, 10 insertions(+), 3 deletions(-)
hw/ppc/virtex_ml507.c +0 -0
index 08e77fb..a00f709 100644

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 5 lines
hw/ppc/virtex_ml507.c +1 -1
@@ -141,11 +141,18 @@ static int xilinx_load_device_tree(hwaddr addr,
 {
    char *path;
    int fdt_size;
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 155

Quoted 13 lines
hw/ppc/virtex_ml507.c +9 -2
    int r;
+    const char *dtb_filename;
 
-    /* Try the local "ppc.dtb" override.  */
-    fdt = load_device_tree("ppc.dtb", &fdt_size);
+    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    if (dtb_filename) {
+        fdt = load_device_tree(dtb_filename, &fdt_size);
+    }
+    if (!fdt) {
+        /* Try the local "ppc.dtb" override.  */
+        fdt = load_device_tree("ppc.dtb", &fdt_size);
+    }
Quoted 3 lines

Could you please just remove the ppc.dtb override option? It's superfluous once we have proper -dtb support.

Edgar, any objections?

Hi,

No objections from my side, I tested the patch and it works fine. I'd prefer to keep the ppc.dtb fallback for backwards compatibility, for example the test image on the wiki relies on it.

Thanks,
Edgar

Quoted 13 lines

Also, you should abort if the user specified a dtb through -dtb and that file could not get loaded.

Alex

Quoted 6 lines
hw/ppc/virtex_ml507.c +0 -0
    if (!fdt) {
        path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
        if (path) {
Signature · 1 line
1.7.10.4
#3 lore raw
Quoted 42 lines · Edgar E. Iglesias
Quoted 41 lines · Alexander Graf
Quoted 2 lines · Efimov Vasily

Please provide a patch description :).

Quoted 9 lines

---
hw/ppc/virtex_ml507.c | 13 ++++++++++---

1 file changed, 10 insertions(+), 3 deletions(-)
hw/ppc/virtex_ml507.c +0 -0
index 08e77fb..a00f709 100644

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 5 lines
hw/ppc/virtex_ml507.c +1 -1
@@ -141,11 +141,18 @@ static int xilinx_load_device_tree(hwaddr addr,
 {
   char *path;
   int fdt_size;
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 155

Quoted 13 lines
hw/ppc/virtex_ml507.c +9 -2
   int r;
+    const char *dtb_filename;
 
-    /* Try the local "ppc.dtb" override.  */
-    fdt = load_device_tree("ppc.dtb", &fdt_size);
+    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    if (dtb_filename) {
+        fdt = load_device_tree(dtb_filename, &fdt_size);
+    }
+    if (!fdt) {
+        /* Try the local "ppc.dtb" override.  */
+        fdt = load_device_tree("ppc.dtb", &fdt_size);
+    }

Could you please just remove the ppc.dtb override option? It's superfluous once we have proper -dtb support.

Quoted 7 lines
Quoted 1 line

Edgar, any objections?

Hi,

No objections from my side, I tested the patch and it works fine. I'd prefer to keep the ppc.dtb fallback for backwards compatibility, for example the test image on the wiki relies on it.

Ah, ok. Then let's make the logic work like this:

if (user provided -dtb) {

  if (load_dtb(user provided dtb)) {
    abort();
  }
} else {
  if (load_dtb("ppc.dtb")) {
    if (load_dtb(find_file(BINARY_DEVICE_TREE_FILE))) {
      abort();
    }

}
}

Alex

#4 lore raw
Quoted 64 lines · Alexander Graf
Quoted 42 lines · Edgar E. Iglesias
Quoted 41 lines · Alexander Graf
Quoted 2 lines · Efimov Vasily

Please provide a patch description :).

Quoted 9 lines

---
hw/ppc/virtex_ml507.c | 13 ++++++++++---

1 file changed, 10 insertions(+), 3 deletions(-)
hw/ppc/virtex_ml507.c +0 -0
index 08e77fb..a00f709 100644

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 5 lines
hw/ppc/virtex_ml507.c +1 -1
@@ -141,11 +141,18 @@ static int xilinx_load_device_tree(hwaddr addr,
 {
   char *path;
   int fdt_size;
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 155

Quoted 13 lines
hw/ppc/virtex_ml507.c +9 -2
   int r;
+    const char *dtb_filename;
 
-    /* Try the local "ppc.dtb" override.  */
-    fdt = load_device_tree("ppc.dtb", &fdt_size);
+    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    if (dtb_filename) {
+        fdt = load_device_tree(dtb_filename, &fdt_size);
+    }
+    if (!fdt) {
+        /* Try the local "ppc.dtb" override.  */
+        fdt = load_device_tree("ppc.dtb", &fdt_size);
+    }

Could you please just remove the ppc.dtb override option? It's superfluous once we have proper -dtb support.

Quoted 7 lines
Quoted 1 line

Edgar, any objections?

Hi,

No objections from my side, I tested the patch and it works fine. I'd prefer to keep the ppc.dtb fallback for backwards compatibility, for example the test image on the wiki relies on it.

Ah, ok. Then let's make the logic work like this:

if (user provided -dtb) {

  if (load_dtb(user provided dtb)) {
    abort();
  }
} else {
  if (load_dtb("ppc.dtb")) {
    if (load_dtb(find_file(BINARY_DEVICE_TREE_FILE))) {
      abort();
    }
Quoted 2 lines

}
}

Hi Alex,

I think that we should only abort() on the -dtb arg case. The other cases are for backwards compatibility.
The dtb used to be optional (useful when for example when running kernels with a builtin dtb) hence the lack of aborts.

Except from that, your suggestion sounds good to me.

Best regards,
Edgar

#5 lore raw
Quoted 68 lines · Edgar E. Iglesias
Quoted 64 lines · Alexander Graf
Quoted 42 lines · Edgar E. Iglesias
Quoted 41 lines · Alexander Graf
Quoted 2 lines · Efimov Vasily

Please provide a patch description :).

Quoted 9 lines

---
hw/ppc/virtex_ml507.c | 13 ++++++++++---

1 file changed, 10 insertions(+), 3 deletions(-)
hw/ppc/virtex_ml507.c +0 -0
index 08e77fb..a00f709 100644

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 5 lines
hw/ppc/virtex_ml507.c +1 -1
@@ -141,11 +141,18 @@ static int xilinx_load_device_tree(hwaddr addr,
 {
  char *path;
  int fdt_size;
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 155

Quoted 13 lines
hw/ppc/virtex_ml507.c +9 -2
  int r;
+    const char *dtb_filename;
 
-    /* Try the local "ppc.dtb" override.  */
-    fdt = load_device_tree("ppc.dtb", &fdt_size);
+    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
+    if (dtb_filename) {
+        fdt = load_device_tree(dtb_filename, &fdt_size);
+    }
+    if (!fdt) {
+        /* Try the local "ppc.dtb" override.  */
+        fdt = load_device_tree("ppc.dtb", &fdt_size);
+    }

Could you please just remove the ppc.dtb override option? It's superfluous once we have proper -dtb support.

Quoted 7 lines
Quoted 1 line

Edgar, any objections?

Hi,

No objections from my side, I tested the patch and it works fine. I'd prefer to keep the ppc.dtb fallback for backwards compatibility, for example the test image on the wiki relies on it.

Ah, ok. Then let's make the logic work like this:

if (user provided -dtb) {

 if (load_dtb(user provided dtb)) {
   abort();
 }
} else {
 if (load_dtb("ppc.dtb")) {
   if (load_dtb(find_file(BINARY_DEVICE_TREE_FILE))) {
     abort();
   }
Quoted 2 lines

}
}

Quoted 8 lines

Hi Alex,

I think that we should only abort() on the -dtb arg case. The other cases are for backwards compatibility.
The dtb used to be optional (useful when for example when running kernels with a builtin dtb) hence the lack of aborts.

Except from that, your suggestion sounds good to me.

Ah, ok. Works for me then.

Eventually the machine should really be converted to generate its device tree dynamically instead of loading a blob, like e500 and spapr do it.

Alex

#6 lore raw
In reply to Edgar E. Iglesias

Am 14.08.2013 13:03, schrieb Edgar E. Iglesias:

Quoted 15 lines · Alexander Graf
Quoted 11 lines

Then let's make the logic work like this:

if (user provided -dtb) {

  if (load_dtb(user provided dtb)) {
    abort();
  }
} else {
  if (load_dtb("ppc.dtb")) {
    if (load_dtb(find_file(BINARY_DEVICE_TREE_FILE))) {
      abort();
    }
Quoted 2 lines

}
}

Quoted 3 lines

Hi Alex,

I think that we should only abort() on the -dtb arg case.

Don't abort() on user-supplied arguments, they're for programmer errors.

Also since Alex has been on vacation, please note that we have a shiny error_report() function that should be preferred over any fprintf(stderr, ...). :) Only downside is it seems to require its own #include. :/

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw
In reply to Alexander Graf

2013/8/14 Alexander Graf <[email protected]>:

Quoted 4 lines

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 2 lines
hw/ppc/virtex_ml507.c +1 -1
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

The last statement is wrong here, NULL is always the same as 0 language-wise. Although the above code is always correct, some will consider it better style to use NULL when dealing with pointer context.
What you probably meant is that the *internal representation* of a null pointer is not guaranteed to be all-0-bits, in contrast to the conceptual null pointer constant (== 0) understood and taken care of by the compiler. But the internal representation is irrelevant here.

http://c-faq.com/null/

Felix

#8 lore raw
Quoted 15 lines · Felix Deichmann

2013/8/14 Alexander Graf <[email protected]>:

Quoted 4 lines

hw/ppc/virtex_ml507.c static int xilinx_load_device_tree(hwaddr addr, · line 144

Quoted 2 lines
hw/ppc/virtex_ml507.c +1 -1
-    void *fdt;
+    void *fdt = 0;

This should be NULL. NULL doesn't have to be 0 according to C IIRC.

The last statement is wrong here, NULL is always the same as 0 language-wise. Although the above code is always correct, some will consider it better style to use NULL when dealing with pointer context.
What you probably meant is that the *internal representation* of a null pointer is not guaranteed to be all-0-bits, in contrast to the conceptual null pointer constant (== 0) understood and taken care of by the compiler. But the internal representation is irrelevant here.

Quoted 1 line

http://c-faq.com/null/

Ah, very nice page explaining everything and more I ever wanted to know about NULL ;).

Alex