Skip to contentSkip to conversation

ppc-for-3.0 queue 20180709

GIT PULL Applied David Gibson 2 participants 18 messages Jul 9, 2018

lore
Share & tools
lore
#0 lore raw

The following changes since commit 43a473993fd9378bf850dcafa68eb6dee8c300f8:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-07-06 18:18:08 +0100)

are available in the Git repository at:

git://github.com/dgibson/qemu.git tags/ppc-for-3.0-20180709

for you to fetch changes up to 51b0d834c414f494410cc94e56886b6584ae3c54:

sam460ex: Make sam460ex_load_device_tree() handle all errors internally (2018-07-09 14:38:45 +1000)

----------------------------------------------------------------
ppc patch queue 2018-07-09

Here's a final pull request before tomorrow's hard freeze.

There are a number of fixes and improvements to the sm501 display driver (not strictly ppc related, but used only on ppc and SH). There's also a handful of unrelated fixes.

Whether all the sm501 changes are bugfixes is somewhat debatable, but Peter has indicated he's ok with merging those for 3.0.

----------------------------------------------------------------
BALATON Zoltan (4):
sm501: Implement i2c part for reading monitor EDID
sm501: Fix support for non-zero frame buffer start address
sm501: Set updated region dirty after 2D operation
sam460ex: Update u-boot-sam460ex firmware

Cédric Le Goater (1):
spapr/vio: quiet down the "irq" property accessors

David Gibson (3):
sam460ex: Check for errors from libfdt functions
sam460ex: Don't check for errors from qemu_fdt_*()
sam460ex: Make sam460ex_load_device_tree() handle all errors internally

Laurent Vivier (1):
target/ppc: fix build on ppc64 host

Mark Cave-Ayland (2):
ppc: fix default VGA display for Mac machines
ppc: fix default VGA display for PReP machines

Philippe Mathieu-Daudé (1):
ppc440_uc: Fix a copy/paste error

Sebastian Bauer (4):
sm501: Perform a full update after palette change
sm501: Use values from the pitch register for 2D operations
sm501: Implement negated destination raster operation mode
sm501: Log unimplemented raster operation modes

 default-configs/ppc-softmmu.mak    |   1 +
 default-configs/ppcemb-softmmu.mak |   1 +
 default-configs/sh4-softmmu.mak    |   2 +
 default-configs/sh4eb-softmmu.mak  |   2 +
 hw/display/sm501.c                 | 230 +++++++++++++++++++++++++++++++++++--
 hw/ppc/mac_newworld.c              |   1 +
 hw/ppc/mac_oldworld.c              |   1 +
 hw/ppc/ppc440_uc.c                 |   2 +-
 hw/ppc/prep.c                      |   2 +
 hw/ppc/sam460ex.c                  |  49 +++-----
 hw/ppc/spapr_vio.c                 |  15 ++-
 pc-bios/u-boot-sam460-20100605.bin | Bin 524288 -> 524288 bytes
 roms/u-boot-sam460ex               |   2 +-
 target/ppc/int_helper.c            |   2 +-
 14 files changed, 258 insertions(+), 52 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 02/16] spapr/vio: quiet down the "irq" property accessors

From: Cédric Le Goater <[email protected]>

commit efe2add7cb7f ("spapr/vio: deprecate the "irq" property") introduced get/set accessors for the "irq" property to warn of its usage, but the warning in the get pollutes the monitor 'info qtree'.

---
 hw/ppc/spapr_vio.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
hw/ppc/spapr_vio.c +12 -3
index daf85130b5..be9af71437 100644
@@ -43,7 +43,16 @@
 
 #include <libfdt.h>
 
-static void spapr_vio_getset_irq(Object *obj, Visitor *v, const char *name,
+static void spapr_vio_get_irq(Object *obj, Visitor *v, const char *name,
+                              void *opaque, Error **errp)
+{
+    Property *prop = opaque;
+    uint32_t *ptr = qdev_get_prop_ptr(DEVICE(obj), prop);
+
+    visit_type_uint32(v, name, ptr, errp);
+}
+
+static void spapr_vio_set_irq(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
     Property *prop = opaque;
@@ -57,8 +66,8 @@ static void spapr_vio_getset_irq(Object *obj, Visitor *v, const char *name,
 
 static const PropertyInfo spapr_vio_irq_propinfo = {
     .name = "irq",
-    .get = spapr_vio_getset_irq,
-    .set = spapr_vio_getset_irq,
+    .get = spapr_vio_get_irq,
+    .set = spapr_vio_set_irq,
 };
 
 static Property spapr_vio_props[] = {
Signature · 1 line
2.17.1
#2 lore raw

[Qemu-devel] [PULL 04/16] sm501: Perform a full update after palette change

In reply to David Gibson

From: Sebastian Bauer <[email protected]>

Changing the palette of a color index has as an immediate effect on all pixels with the corresponding index on real hardware. Performing a full update after a palette change is a simple way to emulate this effect.

---
 hw/display/sm501.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/display/sm501.c +8 -0
index 05c964bea1..b095134d6f 100644
@@ -487,6 +487,7 @@ typedef struct SM501State {
     MemoryRegion twoD_engine_region;
     uint32_t last_width;
     uint32_t last_height;
+    bool do_full_update; /* perform a full update next time */
     I2CBus *i2c_bus;
 
     /* mmio registers */
@@ -1042,6 +1043,7 @@ static void sm501_palette_write(void *opaque, hwaddr addr,
 
     assert(range_covers_byte(0, 0x400 * 3, addr));
     *(uint32_t *)&s->dc_palette[addr] = value;
+    s->do_full_update = true;
 }
 
 static uint64_t sm501_disp_ctrl_read(void *opaque, hwaddr addr,
@@ -1630,6 +1632,12 @@ static void sm501_update_display(void *opaque)
         full_update = 1;
     }
 
+    /* someone else requested a full update */
+    if (s->do_full_update) {
+        s->do_full_update = false;
+        full_update = 1;
+    }
+
     /* draw each line according to conditions */
     snap = memory_region_snapshot_and_clear_dirty(&s->local_mem_region,
               offset, width * height * src_bpp, DIRTY_MEMORY_VGA);
Signature · 1 line
2.17.1
#3 lore raw

[Qemu-devel] [PULL 01/16] ppc: fix default VGA display for Mac machines

In reply to David Gibson

From: Mark Cave-Ayland <[email protected]>

Commit 29f9cef39e "ppc: Include vga cirrus card into the compiling process" changed the default display adapter for all PPC machines to cirrus. Unfortunately it missed setting the default display type to stdvga for both Mac machines causing the display to fail to initialise under OpenBIOS.

Update the MachineClass for both Old World and New World Macs so that the default std(vga) display adapter is the default if no options are specified which fixes the display for the Mac machines.

---
 hw/ppc/mac_newworld.c | 1 +
 hw/ppc/mac_oldworld.c | 1 +
 2 files changed, 2 insertions(+)
hw/ppc/mac_newworld.c +1 -0
index d11980166f..2ca294664b 100644
@@ -525,6 +525,7 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->max_cpus = MAX_CPUS;
     mc->default_boot_order = "cd";
+    mc->default_display = "std";
     mc->kvm_type = core99_kvm_type;
 #ifdef TARGET_PPC64
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("970fx_v3.1");
hw/ppc/mac_oldworld.c +1 -0
index 06ed6f660e..064d7eb30a 100644
@@ -383,6 +383,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data)
     mc->default_boot_order = "cd";
     mc->kvm_type = heathrow_kvm_type;
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("750_v3.1");
+    mc->default_display = "std";
 }
 
 static const TypeInfo ppc_heathrow_machine_info = {
Signature · 1 line
2.17.1
#4 lore raw

[Qemu-devel] [PULL 03/16] sm501: Implement i2c part for reading monitor EDID

In reply to David Gibson

From: BALATON Zoltan <[email protected]>

Emulate the i2c part of SM501 which is used to access the EDID info from a monitor.

The vmstate structure is changed and its version is increased but SM501 is only used on SH and PPC sam460ex machines that don't support cross-version migration.

---
 default-configs/ppc-softmmu.mak    |   1 +
 default-configs/ppcemb-softmmu.mak |   1 +
 default-configs/sh4-softmmu.mak    |   2 +
 default-configs/sh4eb-softmmu.mak  |   2 +
 hw/display/sm501.c                 | 147 ++++++++++++++++++++++++++++-
 5 files changed, 149 insertions(+), 4 deletions(-)
default-configs/ppc-softmmu.mak +1 -0
index 6f12bf84f0..3181bbf163 100644
@@ -25,6 +25,7 @@ CONFIG_ETSEC=y
 CONFIG_SAM460EX=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_SM501=y
+CONFIG_DDC=y
 CONFIG_IDE_SII3112=y
 CONFIG_I2C=y
 CONFIG_BITBANG_I2C=y
default-configs/ppcemb-softmmu.mak +1 -0
index 37af1930b3..ac44f150c6 100644
@@ -17,6 +17,7 @@ CONFIG_XILINX=y
 CONFIG_XILINX_ETHLITE=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_SM501=y
+CONFIG_DDC=y
 CONFIG_IDE_SII3112=y
 CONFIG_I2C=y
 CONFIG_BITBANG_I2C=y
default-configs/sh4-softmmu.mak +2 -0
index 546d855088..caeccd55be 100644
@@ -9,6 +9,8 @@ CONFIG_PFLASH_CFI02=y
 CONFIG_SH4=y
 CONFIG_IDE_MMIO=y
 CONFIG_SM501=y
+CONFIG_I2C=y
+CONFIG_DDC=y
 CONFIG_ISA_TESTDEV=y
 CONFIG_I82378=y
 CONFIG_I8259=y
default-configs/sh4eb-softmmu.mak +2 -0
index 2d3fd49663..53b9cd7b5a 100644
@@ -9,6 +9,8 @@ CONFIG_PFLASH_CFI02=y
 CONFIG_SH4=y
 CONFIG_IDE_MMIO=y
 CONFIG_SM501=y
+CONFIG_I2C=y
+CONFIG_DDC=y
 CONFIG_ISA_TESTDEV=y
 CONFIG_I82378=y
 CONFIG_I8259=y
hw/display/sm501.c +143 -4

223 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

[Qemu-devel] [PULL 09/16] sm501: Set updated region dirty after 2D operation

In reply to David Gibson

From: BALATON Zoltan <[email protected]>

Set the changed memory region dirty after performed a 2D operation to ensure that the screen is updated properly.

---
 hw/display/sm501.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
hw/display/sm501.c +15 -2
index 10ee008eb2..3661a89f60 100644
@@ -715,12 +715,16 @@ static void sm501_2d_operation(SM501State *s)
     /* 1 if rop2 source is the pattern, otherwise the source is the bitmap */
     int rop2_source_is_pattern = (s->twoD_control >> 14) & 0x1;
     int rop = s->twoD_control & 0xFF;
+    uint32_t src_base = s->twoD_source_base & 0x03FFFFFF;
+    uint32_t dst_base = s->twoD_destination_base & 0x03FFFFFF;
 
     /* get frame buffer info */
-    uint8_t *src = s->local_mem + (s->twoD_source_base & 0x03FFFFFF);
-    uint8_t *dst = s->local_mem + (s->twoD_destination_base & 0x03FFFFFF);
+    uint8_t *src = s->local_mem + src_base;
+    uint8_t *dst = s->local_mem + dst_base;
     int src_width = s->twoD_pitch & 0x1FFF;
     int dst_width = (s->twoD_pitch >> 16) & 0x1FFF;
+    int crt = (s->dc_crt_control & SM501_DC_CRT_CONTROL_SEL) ? 1 : 0;
+    int fb_len = get_width(s, crt) * get_height(s, crt) * get_bpp(s, crt);
 
     if (addressing != 0x0) {
         printf("%s: only XY addressing is supported.\n", __func__);
@@ -821,6 +825,15 @@ static void sm501_2d_operation(SM501State *s)
         abort();
         break;
     }
+
+    if (dst_base >= get_fb_addr(s, crt) &&
+        dst_base <= get_fb_addr(s, crt) + fb_len) {
+        int dst_len = MIN(fb_len, ((dst_y + operation_height - 1) * dst_width +
+                           dst_x + operation_width) * (1 << format_flags));
+        if (dst_len) {
+            memory_region_set_dirty(&s->local_mem_region, dst_base, dst_len);
+        }
+    }
 }
 
 static uint64_t sm501_system_config_read(void *opaque, hwaddr addr,
Signature · 1 line
2.17.1
#6 lore raw

[Qemu-devel] [PULL 11/16] target/ppc: fix build on ppc64 host

In reply to David Gibson

From: Laurent Vivier <[email protected]>

When I try to build a ppc64 target on a ppc64 host (gcc 8.1.1), I have:

.../target/ppc/int_helper.c: In function 'helper_vinsertb':
.../target/ppc/int_helper.c:1954:32: error: array subscript 18446744073709551608 is above array bounds of 'uint8_t[16]' {aka 'unsigned char[16]'} [-Werror=array-bounds]

         memmove(&r->u8[index], &b->u8[8 - sizeof(r->element)],              \
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.../target/ppc/int_helper.c:1965:1: note: in expansion of macro 'VINSERT'

If we compare with the macro for ppc64le, we can see sizeof(r->element[0]) should be used instead of sizeof(r->element).

And VINSERT uses only u8, u16, u32 and u64, so the maximum value of sizeof(r->element[0]) is 8

---
 target/ppc/int_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/int_helper.c +1 -1
index 03d37da79f..d52338ed71 100644
@@ -1951,7 +1951,7 @@ VSPLT(w, u32)
 #define VINSERT(suffix, element)                                            \
     void helper_vinsert##suffix(ppc_avr_t *r, ppc_avr_t *b, uint32_t index) \
     {                                                                       \
-        memmove(&r->u8[index], &b->u8[8 - sizeof(r->element)],              \
+        memmove(&r->u8[index], &b->u8[8 - sizeof(r->element[0])],           \
                sizeof(r->element[0]));                                      \
     }
 #else
Signature · 1 line
2.17.1
#7 lore raw

[Qemu-devel] [PULL 05/16] sm501: Use values from the pitch register for 2D operations

In reply to David Gibson

From: Sebastian Bauer <[email protected]>

Before, crt_h_total was used for src_width and dst_width. This is a property of the current display setting and not relevant for the 2D operation that also can be done off-screen. The pitch register's purpose is to describe line pitch relevant of the 2D operation.

---
 hw/display/sm501.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/display/sm501.c +2 -2
index b095134d6f..d4878f01c0 100644
@@ -709,8 +709,8 @@ static void sm501_2d_operation(SM501State *s)
     /* get frame buffer info */
     uint8_t *src = s->local_mem + (s->twoD_source_base & 0x03FFFFFF);
     uint8_t *dst = s->local_mem + (s->twoD_destination_base & 0x03FFFFFF);
-    int src_width = (s->dc_crt_h_total & 0x00000FFF) + 1;
-    int dst_width = (s->dc_crt_h_total & 0x00000FFF) + 1;
+    int src_width = s->twoD_pitch & 0x1FFF;
+    int dst_width = (s->twoD_pitch >> 16) & 0x1FFF;
 
     if (addressing != 0x0) {
         printf("%s: only XY addressing is supported.\n", __func__);
Signature · 1 line
2.17.1
#8 lore raw

[Qemu-devel] [PULL 07/16] sm501: Log unimplemented raster operation modes

In reply to David Gibson

From: Sebastian Bauer <[email protected]>

The sm501 currently implements only a very limited set of raster operation modes. After this change, unknown raster operation modes are logged so these can be easily spotted.

---
 hw/display/sm501.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
hw/display/sm501.c +23 -0
index 0b44d95169..ebd139006e 100644
@@ -706,6 +706,8 @@ static void sm501_2d_operation(SM501State *s)
     int format_flags = (s->twoD_stretch >> 20) & 0x3;
     int addressing = (s->twoD_stretch >> 16) & 0xF;
     int rop_mode = (s->twoD_control >> 15) & 0x1; /* 1 for rop2, else rop3 */
+    /* 1 if rop2 source is the pattern, otherwise the source is the bitmap */
+    int rop2_source_is_pattern = (s->twoD_control >> 14) & 0x1;
     int rop = s->twoD_control & 0xFF;
 
     /* get frame buffer info */
@@ -719,6 +721,27 @@ static void sm501_2d_operation(SM501State *s)
         abort();
     }
 
+    if (rop_mode == 0) {
+        if (rop != 0xcc) {
+            /* Anything other than plain copies are not supported */
+            qemu_log_mask(LOG_UNIMP, "sm501: rop3 mode with rop %x is not "
+                          "supported.\n", rop);
+        }
+    } else {
+        if (rop2_source_is_pattern && rop != 0x5) {
+            /* For pattern source, we support only inverse dest */
+            qemu_log_mask(LOG_UNIMP, "sm501: rop2 source being the pattern and "
+                          "rop %x is not supported.\n", rop);
+        } else {
+            if (rop != 0x5 && rop != 0xc) {
+                /* Anything other than plain copies or inverse dest is not
+                 * supported */
+                qemu_log_mask(LOG_UNIMP, "sm501: rop mode %x is not "
+                              "supported.\n", rop);
+            }
+        }
+    }
+
     if ((s->twoD_source_base & 0x08000000) ||
         (s->twoD_destination_base & 0x08000000)) {
         printf("%s: only local memory is supported.\n", __func__);
Signature · 1 line
2.17.1
#9 lore raw

[Qemu-devel] [PULL 12/16] ppc: fix default VGA display for PReP machines

In reply to David Gibson

From: Mark Cave-Ayland <[email protected]>

Commit 29f9cef "ppc: Include vga cirrus card into the compiling process" changed the default display adapter for all PPC machines to cirrus. Unfortunately it missed setting the default display type to stdvga for both PReP machines causing the display to fail to initialise under OpenHackWare.

Update the MachineClass for both prep and 40p machines so that the default std(vga) display adapter is the default if no options are specified which fixes the display for the PReP machines.

---
 hw/ppc/prep.c | 2 ++
 1 file changed, 2 insertions(+)
hw/ppc/prep.c +2 -0
index 6689407b3d..3401570d98 100644
@@ -682,6 +682,7 @@ static void prep_machine_init(MachineClass *mc)
     mc->max_cpus = MAX_CPUS;
     mc->default_boot_order = "cad";
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("602");
+    mc->default_display = "std";
 }
 
 static int prep_set_cmos_checksum(DeviceState *dev, void *opaque)
@@ -888,6 +889,7 @@ static void ibm_40p_machine_init(MachineClass *mc)
     mc->block_default_type = IF_SCSI;
     mc->default_boot_order = "c";
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("604");
+    mc->default_display = "std";
 }
 
 DEFINE_MACHINE("40p", ibm_40p_machine_init)
Signature · 1 line
2.17.1
#10 lore raw

[Qemu-devel] [PULL 06/16] sm501: Implement negated destination raster operation mode

In reply to David Gibson

From: Sebastian Bauer <[email protected]>

Add support for the negated destination operation mode. This is used e.g. by AmigaOS for the INVERSEVID drawing mode. With this change, the cursor in the shell and non-immediate window adjustment are working now.

---
 hw/display/sm501.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
hw/display/sm501.c +11 -1
index d4878f01c0..0b44d95169 100644
@@ -705,6 +705,8 @@ static void sm501_2d_operation(SM501State *s)
     uint32_t color = s->twoD_foreground;
     int format_flags = (s->twoD_stretch >> 20) & 0x3;
     int addressing = (s->twoD_stretch >> 16) & 0xF;
+    int rop_mode = (s->twoD_control >> 15) & 0x1; /* 1 for rop2, else rop3 */
+    int rop = s->twoD_control & 0xFF;
 
     /* get frame buffer info */
     uint8_t *src = s->local_mem + (s->twoD_source_base & 0x03FFFFFF);
@@ -729,6 +731,8 @@ static void sm501_2d_operation(SM501State *s)
         int y, x, index_d, index_s;                                           \
         for (y = 0; y < operation_height; y++) {                              \
             for (x = 0; x < operation_width; x++) {                           \
+                _pixel_type val;                                              \
+                                                                              \
                 if (rtl) {                                                    \
                     index_s = ((src_y - y) * src_width + src_x - x) * _bpp;   \
                     index_d = ((dst_y - y) * dst_width + dst_x - x) * _bpp;   \
@@ -736,7 +740,13 @@ static void sm501_2d_operation(SM501State *s)
                     index_s = ((src_y + y) * src_width + src_x + x) * _bpp;   \
                     index_d = ((dst_y + y) * dst_width + dst_x + x) * _bpp;   \
                 }                                                             \
-                *(_pixel_type *)&dst[index_d] = *(_pixel_type *)&src[index_s];\
+                if (rop_mode == 1 && rop == 5) {                              \
+                    /* Invert dest */                                         \
+                    val = ~*(_pixel_type *)&dst[index_d];                     \
+                } else {                                                      \
+                    val = *(_pixel_type *)&src[index_s];                      \
+                }                                                             \
+                *(_pixel_type *)&dst[index_d] = val;                          \
             }                                                                 \
         }                                                                     \
     }
Signature · 1 line
2.17.1
#11 lore raw

[Qemu-devel] [PULL 13/16] sam460ex: Update u-boot-sam460ex firmware

In reply to David Gibson

From: BALATON Zoltan <[email protected]>

Update the submodule and u-boot-sam460-20100605.bin to include following fixes from Sebastian Bauer:
- Fix build with newer gcc
- Decrease unnecessary delay which fixes slow booting from CD

---
 pc-bios/u-boot-sam460-20100605.bin | Bin 524288 -> 524288 bytes
 roms/u-boot-sam460ex               |   2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
pc-bios/u-boot-sam460-20100605.bin binary +0 -0
index 99408f8e957b26e735e5befa98fa3d51a90d95f6..e17de77c1974382144625632c709c29a1a86edef 100755
GIT binary patch
roms/u-boot-sam460ex +1 -1
index 8ee007c421..60b3916f33 160000
@@ -1 +1 @@
-Subproject commit 8ee007c4216fd6a0d760589e8405ce4494497aa0
+Subproject commit 60b3916f33e617a815973c5a6df77055b2e3a588
Signature · 1 line
2.17.1
#12 lore raw

[Qemu-devel] [PULL 08/16] sm501: Fix support for non-zero frame buffer start address

In reply to David Gibson

From: BALATON Zoltan <[email protected]>

Display updates and drawing hardware cursor did not work when frame buffer address was non-zero. Fix this by taking the frame buffer address into account in these cases. This fixes screen dragging on AmigaOS. Based on patch by Sebastian Bauer.

---
 hw/display/sm501.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
hw/display/sm501.c +16 -3
index ebd139006e..10ee008eb2 100644
@@ -586,6 +586,11 @@ static uint32_t get_local_mem_size_index(uint32_t size)
     return index;
 }
 
+static ram_addr_t get_fb_addr(SM501State *s, int crt)
+{
+    return (crt ? s->dc_crt_fb_addr : s->dc_panel_fb_addr) & 0x3FFFFF0;
+}
+
 static inline int get_width(SM501State *s, int crt)
 {
     int width = crt ? s->dc_crt_h_total : s->dc_panel_h_total;
@@ -688,7 +693,8 @@ static inline void hwc_invalidate(SM501State *s, int crt)
     start *= w * bpp;
     end *= w * bpp;
 
-    memory_region_set_dirty(&s->local_mem_region, start, end - start);
+    memory_region_set_dirty(&s->local_mem_region,
+                            get_fb_addr(s, crt) + start, end - start);
 }
 
 static void sm501_2d_operation(SM501State *s)
@@ -1213,6 +1219,9 @@ static void sm501_disp_ctrl_write(void *opaque, hwaddr addr,
         break;
     case SM501_DC_PANEL_FB_ADDR:
         s->dc_panel_fb_addr = value & 0x8FFFFFF0;
+        if (value & 0x8000000) {
+            qemu_log_mask(LOG_UNIMP, "Panel external memory not supported\n");
+        }
         break;
     case SM501_DC_PANEL_FB_OFFSET:
         s->dc_panel_fb_offset = value & 0x3FF03FF0;
@@ -1273,6 +1282,9 @@ static void sm501_disp_ctrl_write(void *opaque, hwaddr addr,
         break;
     case SM501_DC_CRT_FB_ADDR:
         s->dc_crt_fb_addr = value & 0x8FFFFFF0;
+        if (value & 0x8000000) {
+            qemu_log_mask(LOG_UNIMP, "CRT external memory not supported\n");
+        }
         break;
     case SM501_DC_CRT_FB_OFFSET:
         s->dc_crt_fb_offset = value & 0x3FF03FF0;
@@ -1615,7 +1627,7 @@ static void sm501_update_display(void *opaque)
     draw_hwc_line_func *draw_hwc_line = NULL;
     int full_update = 0;
     int y_start = -1;
-    ram_addr_t offset = 0;
+    ram_addr_t offset;
     uint32_t *palette;
     uint8_t hwc_palette[3 * 3];
     uint8_t *hwc_src = NULL;
@@ -1672,9 +1684,10 @@ static void sm501_update_display(void *opaque)
     }
 
     /* draw each line according to conditions */
+    offset = get_fb_addr(s, crt);
     snap = memory_region_snapshot_and_clear_dirty(&s->local_mem_region,
               offset, width * height * src_bpp, DIRTY_MEMORY_VGA);
-    for (y = 0, offset = 0; y < height; y++, offset += width * src_bpp) {
+    for (y = 0; y < height; y++, offset += width * src_bpp) {
         int update, update_hwc;
 
         /* check if hardware cursor is enabled and we're within its range */
Signature · 1 line
2.17.1
#13 lore raw

[Qemu-devel] [PULL 10/16] ppc440_uc: Fix a copy/paste error

In reply to David Gibson

From: Philippe Mathieu-Daudé <[email protected]>

Missed in 3c409c1927e, hopefully reported by Coverity.

Fixes Coverity CID 1393788 (Copy-paste error)
---
 hw/ppc/ppc440_uc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/ppc440_uc.c +1 -1
index 0bbaa6844a..09ccda548f 100644
@@ -935,7 +935,7 @@ static void dcr_write_dma(void *opaque, int dcrn, uint32_t val)
                     if (wptr) {
                         cpu_physical_memory_unmap(wptr, wlen, 1, didx);
                     }
-                    if (wptr) {
+                    if (rptr) {
                         cpu_physical_memory_unmap(rptr, rlen, 0, sidx);
                     }
                 }
Signature · 1 line
2.17.1
#14 lore raw

[Qemu-devel] [PULL 15/16] sam460ex: Don't check for errors from qemu_fdt_*()

In reply to David Gibson

The qemu_fdt_*() helper functions already exit with a message instead of returning errors, so we don't need to check for errors in the caller.

---
 hw/ppc/sam460ex.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)
hw/ppc/sam460ex.c +6 -20
index 1661e036f3..8194f32cd3 100644
@@ -276,32 +276,18 @@ static int sam460ex_load_device_tree(hwaddr addr,
 
     /* Manipulate device tree in memory. */
 
-    ret = qemu_fdt_setprop(fdt, "/memory", "reg", mem_reg_property,
-                               sizeof(mem_reg_property));
-    if (ret < 0) {
-        error_report("couldn't set /memory/reg");
-    }
+    qemu_fdt_setprop(fdt, "/memory", "reg", mem_reg_property,
+                     sizeof(mem_reg_property));
 
     /* default FDT doesn't have a /chosen node... */
     qemu_fdt_add_subnode(fdt, "/chosen");
 
-    ret = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
-                                    initrd_base);
-    if (ret < 0) {
-        error_report("couldn't set /chosen/linux,initrd-start");
-    }
+    qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", initrd_base);
 
-    ret = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
-                                    (initrd_base + initrd_size));
-    if (ret < 0) {
-        error_report("couldn't set /chosen/linux,initrd-end");
-    }
+    qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+                          (initrd_base + initrd_size));
 
-    ret = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
-                                      kernel_cmdline);
-    if (ret < 0) {
-        error_report("couldn't set /chosen/bootargs");
-    }
+    qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", kernel_cmdline);
 
     /* Copy data from the host device tree into the guest. Since the guest can
      * directly access the timebase without host involvement, we must expose
Signature · 1 line
2.17.1
#15 lore raw

[Qemu-devel] [PULL 16/16] sam460ex: Make sam460ex_load_device_tree() handle all errors internally

In reply to David Gibson

sam460ex_load_device_tree() handles nearly all possible errors by simply exiting (within helper functions and macros). It handles two early error cases by returning an error.

There's no particular point to this, so make it handle those directly as well, removing the need for the caller to handle a failure. As a bonus it gives us more specific error messages.

---
 hw/ppc/sam460ex.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
hw/ppc/sam460ex.c +6 -12
index 8194f32cd3..e2b7028843 100644
@@ -255,7 +255,6 @@ static int sam460ex_load_device_tree(hwaddr addr,
                                      hwaddr initrd_size,
                                      const char *kernel_cmdline)
 {
-    int ret = -1;
     uint32_t mem_reg_property[] = { 0, 0, cpu_to_be32(ramsize) };
     char *filename;
     int fdt_size;
@@ -266,12 +265,14 @@ static int sam460ex_load_device_tree(hwaddr addr,
 
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
     if (!filename) {
-        goto out;
+        error_report("Couldn't find dtb file `%s'", BINARY_DEVICE_TREE_FILE);
+        exit(1);
     }
     fdt = load_device_tree(filename, &fdt_size);
     g_free(filename);
-    if (fdt == NULL) {
-        goto out;
+    if (!fdt) {
+        error_report("Couldn't load dtb file `%s'", filename);
+        exit(1);
     }
 
     /* Manipulate device tree in memory. */
@@ -325,11 +326,8 @@ static int sam460ex_load_device_tree(hwaddr addr,
 
     rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
     g_free(fdt);
-    ret = fdt_size;
-
-out:
 
-    return ret;
+    return fdt_size;
 }
 
 /* Create reset TLB entries for BookE, mapping only the flash memory.  */
@@ -599,10 +597,6 @@ static void sam460ex_init(MachineState *machine)
         dt_size = sam460ex_load_device_tree(FDT_ADDR, machine->ram_size,
                                     RAMDISK_ADDR, initrd_size,
                                     machine->kernel_cmdline);
-        if (dt_size < 0) {
-            error_report("couldn't load device tree");
-            exit(1);
-        }
 
         boot_info->dt_base = FDT_ADDR;
         boot_info->dt_size = dt_size;
Signature · 1 line
2.17.1
#16 lore raw

[Qemu-devel] [PULL 14/16] sam460ex: Check for errors from libfdt functions

In reply to David Gibson

In a couple of places sam460ex_load_device_tree() calls "raw" libfdt functions which can fail, but doesn't check for error codes. At best, if these fail the guest will be silently started in a non-standard state, or it could fail entirely.

Fix this by using the _FDT() helper macro which aborts on a libfdt failure.

---
 hw/ppc/sam460ex.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/sam460ex.c +3 -2
index 7eed2ec601..1661e036f3 100644
@@ -36,6 +36,7 @@
 #include "hw/i2c/ppc4xx_i2c.h"
 #include "hw/i2c/smbus.h"
 #include "hw/usb/hcd-ehci.h"
+#include "hw/ppc/fdt.h"
 
 #include <libfdt.h>
 
@@ -318,13 +319,13 @@ static int sam460ex_load_device_tree(hwaddr addr,
     /* Remove cpm node if it exists (it is not emulated) */
     offset = fdt_path_offset(fdt, "/cpm");
     if (offset >= 0) {
-        fdt_nop_node(fdt, offset);
+        _FDT(fdt_nop_node(fdt, offset));
     }
 
     /* set serial port clocks */
     offset = fdt_node_offset_by_compatible(fdt, -1, "ns16550");
     while (offset >= 0) {
-        fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
+        _FDT(fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ));
         offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");
     }
 
Signature · 1 line
2.17.1
#17 lore raw
In reply to David Gibson
Quoted 17 lines · David Gibson

The following changes since commit 43a473993fd9378bf850dcafa68eb6dee8c300f8:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-07-06 18:18:08 +0100)

are available in the Git repository at:

git://github.com/dgibson/qemu.git tags/ppc-for-3.0-20180709

for you to fetch changes up to 51b0d834c414f494410cc94e56886b6584ae3c54:

sam460ex: Make sam460ex_load_device_tree() handle all errors internally (2018-07-09 14:38:45 +1000)

----------------------------------------------------------------
ppc patch queue 2018-07-09

Here's a final pull request before tomorrow's hard freeze.

Quoted 8 lines

There are a number of fixes and improvements to the sm501 display driver (not strictly ppc related, but used only on ppc and SH). There's also a handful of unrelated fixes.

Whether all the sm501 changes are bugfixes is somewhat debatable, but Peter has indicated he's ok with merging those for 3.0.

----------------------------------------------------------------

Applied, thanks.

-- PMM