qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [RFC 14/14] ppc/spapr/vga: Switch VGA endian on H_SET_MODE
Date: Tue, 24 Jun 2014 09:11:08 +1000	[thread overview]
Message-ID: <1403565068-15229-15-git-send-email-benh@kernel.crashing.org> (raw)
In-Reply-To: <1403565068-15229-1-git-send-email-benh@kernel.crashing.org>

When the guest switches the interrupt endian mode, which essentially
means a global machine endian switch, we want to change the VGA
framebuffer endian mode as well in order to be backward compatible
with existing guests who don't know about the new endian control
register.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 hw/display/vga-pci.c   |  8 ++++++++
 hw/ppc/spapr_hcall.c   |  2 ++
 hw/ppc/spapr_pci.c     | 26 ++++++++++++++++++++++++++
 include/hw/pci/pci.h   |  1 +
 include/hw/ppc/spapr.h |  1 +
 5 files changed, 38 insertions(+)

diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index 0351d94..e2abc8c 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -212,6 +212,14 @@ static void pci_secondary_vga_reset(DeviceState *dev)
     vga_common_reset(&d->vga);
 }
 
+void pci_vga_switch_fb_endian(DeviceState *dev, bool big_endian)
+{
+    PCIVGAState *d = DO_UPCAST(PCIVGAState, dev.qdev, dev);
+    VGACommonState *s = &d->vga;
+
+    s->big_endian_fb = big_endian;
+}
+
 static Property vga_pci_properties[] = {
     DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
     DEFINE_PROP_BIT("mmio", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_MMIO, true),
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 7952077..e52f22d 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -731,12 +731,14 @@ static target_ulong h_set_mode_resouce_le(PowerPCCPU *cpu,
         CPU_FOREACH(cs) {
             set_spr(cs, SPR_LPCR, 0, LPCR_ILE);
         }
+        spapr_pci_switch_vga(true);
         return H_SUCCESS;
 
     case H_SET_MODE_ENDIAN_LITTLE:
         CPU_FOREACH(cs) {
             set_spr(cs, SPR_LPCR, LPCR_ILE, LPCR_ILE);
         }
+        spapr_pci_switch_vga(false);
         return H_SUCCESS;
     }
 
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 988f8cb..99ae3cd 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -926,3 +926,29 @@ static void spapr_pci_register_types(void)
 }
 
 type_init(spapr_pci_register_types)
+
+static int spapr_switch_one_vga(DeviceState *dev, void *opaque)
+{
+    bool be = *(bool *)opaque;
+
+    if (!strcmp(object_get_typename(OBJECT(dev)), "VGA")) {
+        pci_vga_switch_fb_endian(dev, be);
+    }
+    return 0;
+}
+
+void spapr_pci_switch_vga(bool big_endian)
+{
+    sPAPRPHBState *sphb;
+
+    /*
+     * For backward compatibility with existing guests, we switch
+     * the endianness of the VGA controller when changing the guest
+     * interrupt mode
+     */
+    QLIST_FOREACH(sphb, &spapr->phbs, list) {
+        BusState *bus = &PCI_HOST_BRIDGE(sphb)->bus->qbus;
+        qbus_walk_children(bus, spapr_switch_one_vga, NULL, NULL, NULL,
+                           &big_endian);
+    }
+}
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 8c25ae5..bea4aff 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -373,6 +373,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
                                const char *default_devaddr);
 
 PCIDevice *pci_vga_init(PCIBus *bus);
+void pci_vga_switch_fb_endian(DeviceState *dev, bool big_endian);
 
 int pci_bus_num(PCIBus *s);
 void pci_for_each_device(PCIBus *bus, int bus_num,
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 08c301f..e3e7aff 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -425,5 +425,6 @@ int spapr_dma_dt(void *fdt, int node_off, const char *propname,
                  uint32_t liobn, uint64_t window, uint32_t size);
 int spapr_tcet_dma_dt(void *fdt, int node_off, const char *propname,
                       sPAPRTCETable *tcet);
+void spapr_pci_switch_vga(bool big_endian);
 
 #endif /* !defined (__HW_SPAPR_H__) */
-- 
1.9.1

  parent reply	other threads:[~2014-06-23 23:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 23:10 [Qemu-devel] [RFC 00/14] VGA cleanups and endian control Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 01/14] vga: Create direct sufaces for depth 24 too Benjamin Herrenschmidt
2014-07-01  7:09   ` Gerd Hoffmann
2014-07-01  9:31     ` Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 02/14] ui: Remove unused QEMU_BIG_ENDIAN_FLAG Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 03/14] vga: Start cutting out non-32bpp conversion support Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 04/14] vga: Remove remainder of old conversion cruft Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 05/14] vga: Remove unused vga_draw_line24() and vga_draw_line32() Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 06/14] vga: 15 and 16bpp draw functions are "swapping" only Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 07/14] vga: Remove rgb_to_pixel indirection Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 08/14] vga: Simplify vga_draw_blank() a bit Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 09/14] cirrus: Remove non-32bpp cursor drawing Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 10/14] vga: Remove some "should be done in BIOS" comments Benjamin Herrenschmidt
2014-06-30 11:31   ` Gerd Hoffmann
2014-06-23 23:11 ` [Qemu-devel] [RFC 11/14] vga: Make fb endian a common state variable Benjamin Herrenschmidt
2014-06-23 23:24   ` Peter Maydell
2014-06-23 23:44     ` Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 12/14] vga: Rename vga_template.h to vga-helpers.h Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 13/14] vga: Add endian control register Benjamin Herrenschmidt
2014-06-23 23:48   ` Benjamin Herrenschmidt
2014-06-30 11:38   ` Gerd Hoffmann
2014-06-30 12:34     ` Benjamin Herrenschmidt
2014-06-23 23:11 ` Benjamin Herrenschmidt [this message]
2014-06-30 11:49   ` [Qemu-devel] [RFC 14/14] ppc/spapr/vga: Switch VGA endian on H_SET_MODE Gerd Hoffmann
2014-06-30 12:34     ` Benjamin Herrenschmidt
2014-06-30 11:50 ` [Qemu-devel] [RFC 00/14] VGA cleanups and endian control Gerd Hoffmann
2014-06-30 12:36   ` Benjamin Herrenschmidt
2014-06-30 13:03     ` Gerd Hoffmann
2014-06-30 13:36       ` Benjamin Herrenschmidt

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=1403565068-15229-15-git-send-email-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@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).