Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-3.1-201809…
Browse files Browse the repository at this point in the history
…25' into staging

ppc patch queue 2018-09-25

Here are the accumulated ppc target patches for the last several
weeks. Highlights are:
   * A number of 40p / PReP cleanups
   * Preliminary irq rework on the pseries machine towards the new
     XIVE interrupt controller

There are a few patches which make small changes to generic device and
arm code as prerequisites to the 40p interrupt routing cleanup.  They
have acks from the relevant maintainers.

# gpg: Signature made Tue 25 Sep 2018 08:00:06 BST
# gpg:                using RSA key 6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>"
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>"
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>"
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>"
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dgibson/tags/ppc-for-3.1-20180925:
  40p: add fixed IRQ routing for LSI SCSI device
  lsi53c895a: add optional external IRQ via qdev
  scsi: remove unused lsi53c895a_create() and lsi53c810_create() functions
  scsi: move lsi53c8xx_create() callers to lsi53c8xx_handle_legacy_cmdline()
  scsi: add lsi53c8xx_handle_legacy_cmdline() function
  sm501: Adjust endianness of pixel value in rectangle fill
  spapr_pci: add an extra 'nr_msis' argument to spapr_populate_pci_dt
  spapr: increase the size of the IRQ number space
  spapr: introduce a spapr_irq class 'nr_msis' attribute
  40p: use OR gate to wire up raven PCI interrupts
  raven: some minor IRQ-related tidy-ups
  hw/ppc: on 40p machine, change default firmware to OpenBIOS
  target/ppc/cpu-models: Re-group the 970 CPUs together again
  Record history of ppcemb target in common.json

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Sep 25, 2018
2 parents 32556ac + 0358687 commit 506e4a0
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 69 deletions.
3 changes: 2 additions & 1 deletion hw/arm/realview.c
Expand Up @@ -257,7 +257,8 @@ static void realview_init(MachineState *machine,
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
lsi53c895a_create(pci_bus);
dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
lsi53c8xx_handle_legacy_cmdline(dev);
n--;
}
}
Expand Down
3 changes: 2 additions & 1 deletion hw/arm/versatilepb.c
Expand Up @@ -278,7 +278,8 @@ static void versatile_init(MachineState *machine, int board_id)
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
lsi53c895a_create(pci_bus);
dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
lsi53c8xx_handle_legacy_cmdline(dev);
n--;
}

Expand Down
3 changes: 3 additions & 0 deletions hw/display/sm501.c
Expand Up @@ -39,6 +39,7 @@
#include "hw/i2c/i2c-ddc.h"
#include "qemu/range.h"
#include "ui/pixel_ops.h"
#include "qemu/bswap.h"

/*
* Status: 2010/05/07
Expand Down Expand Up @@ -812,9 +813,11 @@ static void sm501_2d_operation(SM501State *s)
FILL_RECT(1, uint8_t);
break;
case 1:
color = cpu_to_le16(color);
FILL_RECT(2, uint16_t);
break;
case 2:
color = cpu_to_le32(color);
FILL_RECT(4, uint32_t);
break;
}
Expand Down
4 changes: 3 additions & 1 deletion hw/hppa/machine.c
Expand Up @@ -59,6 +59,7 @@ static void machine_hppa_init(MachineState *machine)
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
DeviceState *dev;
PCIBus *pci_bus;
ISABus *isa_bus;
qemu_irq rtc_irq, serial_irq;
Expand Down Expand Up @@ -115,7 +116,8 @@ static void machine_hppa_init(MachineState *machine)
}

/* SCSI disk setup. */
lsi53c895a_create(pci_bus);
dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
lsi53c8xx_handle_legacy_cmdline(dev);

/* Network setup. e1000 is good enough, failing Tulip support. */
for (i = 0; i < nb_nics; i++) {
Expand Down
34 changes: 27 additions & 7 deletions hw/pci-host/prep.c
Expand Up @@ -32,6 +32,7 @@
#include "hw/pci/pci_host.h"
#include "hw/i386/pc.h"
#include "hw/loader.h"
#include "hw/or-irq.h"
#include "exec/address-spaces.h"
#include "elf.h"

Expand All @@ -55,7 +56,8 @@ typedef struct RavenPCIState {
typedef struct PRePPCIState {
PCIHostState parent_obj;

qemu_irq irq[PCI_NUM_PINS];
qemu_or_irq *or_irq;
qemu_irq pci_irqs[PCI_NUM_PINS];
PCIBus pci_bus;
AddressSpace pci_io_as;
MemoryRegion pci_io;
Expand All @@ -69,6 +71,7 @@ typedef struct PRePPCIState {
RavenPCIState pci_dev;

int contiguous_map;
bool is_legacy_prep;
} PREPPCIState;

#define BIOS_SIZE (1 * MiB)
Expand Down Expand Up @@ -194,9 +197,9 @@ static int raven_map_irq(PCIDevice *pci_dev, int irq_num)

static void raven_set_irq(void *opaque, int irq_num, int level)
{
qemu_irq *pic = opaque;
PREPPCIState *s = opaque;

qemu_set_irq(pic[irq_num] , level);
qemu_set_irq(s->pci_irqs[irq_num], level);
}

static AddressSpace *raven_pcihost_set_iommu(PCIBus *bus, void *opaque,
Expand All @@ -222,14 +225,28 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
MemoryRegion *address_space_mem = get_system_memory();
int i;

for (i = 0; i < PCI_NUM_PINS; i++) {
sysbus_init_irq(dev, &s->irq[i]);
if (s->is_legacy_prep) {
for (i = 0; i < PCI_NUM_PINS; i++) {
sysbus_init_irq(dev, &s->pci_irqs[i]);
}
} else {
/* According to PReP specification section 6.1.6 "System Interrupt
* Assignments", all PCI interrupts are routed via IRQ 15 */
s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
object_property_set_int(OBJECT(s->or_irq), PCI_NUM_PINS, "num-lines",
&error_fatal);
object_property_set_bool(OBJECT(s->or_irq), true, "realized",
&error_fatal);
sysbus_init_irq(dev, &s->or_irq->out_irq);

for (i = 0; i < PCI_NUM_PINS; i++) {
s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
}
}

qdev_init_gpio_in(d, raven_change_gpio, 1);

pci_bus_irqs(&s->pci_bus, raven_set_irq, raven_map_irq, s->irq,
PCI_NUM_PINS);
pci_bus_irqs(&s->pci_bus, raven_set_irq, raven_map_irq, s, PCI_NUM_PINS);

memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, s,
"pci-conf-idx", 4);
Expand Down Expand Up @@ -383,6 +400,9 @@ static Property raven_pcihost_properties[] = {
DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
EM_NONE),
DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
/* Temporary workaround until legacy prep machine is removed */
DEFINE_PROP_BOOL("is-legacy-prep", PREPPCIState, is_legacy_prep,
false),
DEFINE_PROP_END_OF_LIST()
};

Expand Down
21 changes: 11 additions & 10 deletions hw/ppc/prep.c
Expand Up @@ -502,6 +502,7 @@ static void ppc_prep_init(MachineState *machine)
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
qdev_prop_set_bit(dev, "is-legacy-prep", true);
pcihost = PCI_HOST_BRIDGE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev);
Expand Down Expand Up @@ -620,7 +621,7 @@ static void ibm_40p_init(MachineState *machine)
CPUPPCState *env = NULL;
uint16_t cmos_checksum;
PowerPCCPU *cpu;
DeviceState *dev;
DeviceState *dev, *i82378_dev;
SysBusDevice *pcihost, *s;
Nvram *m48t59 = NULL;
PCIBus *pci_bus;
Expand Down Expand Up @@ -651,7 +652,7 @@ static void ibm_40p_init(MachineState *machine)
/* PCI host */
dev = qdev_create(NULL, "raven-pcihost");
if (!bios_name) {
bios_name = BIOS_FILENAME;
bios_name = "openbios-ppc";
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
Expand All @@ -665,14 +666,11 @@ static void ibm_40p_init(MachineState *machine)
}

/* PCI -> ISA bridge */
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
qdev_connect_gpio_out(dev, 0,
i82378_dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
qdev_connect_gpio_out(i82378_dev, 0,
cpu->env.irq_inputs[PPC6xx_INPUT_INT]);
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13));
sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13));
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(i82378_dev, 15));
isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));

/* Memory controller */
dev = DEVICE(isa_create(isa_bus, "rs6000-mc"));
Expand Down Expand Up @@ -702,7 +700,10 @@ static void ibm_40p_init(MachineState *machine)
qdev_prop_set_uint32(dev, "equipment", 0xc0);
qdev_init_nofail(dev);

lsi53c810_create(pci_bus, PCI_DEVFN(1, 0));
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(1, 0),
"lsi53c810"));
lsi53c8xx_handle_legacy_cmdline(dev);
qdev_connect_gpio_out(dev, 0, qdev_get_gpio_in(i82378_dev, 13));

/* XXX: s3-trio at PCI_DEVFN(2, 0) */
pci_vga_init(pci_bus);
Expand Down
3 changes: 2 additions & 1 deletion hw/ppc/spapr.c
Expand Up @@ -1267,7 +1267,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
}

QLIST_FOREACH(phb, &spapr->phbs, list) {
ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);
ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt, smc->irq->nr_msis);
if (ret < 0) {
error_report("couldn't setup PCI devices in fdt");
exit(1);
Expand Down Expand Up @@ -3971,6 +3971,7 @@ static void spapr_machine_3_0_class_options(MachineClass *mc)
SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_0);

smc->legacy_irq_allocation = true;
smc->irq = &spapr_irq_xics_legacy;
}

DEFINE_SPAPR_MACHINE(3_0, "3.0", false);
Expand Down
22 changes: 20 additions & 2 deletions hw/ppc/spapr_irq.c
Expand Up @@ -99,7 +99,7 @@ static void spapr_irq_init_xics(sPAPRMachineState *spapr, Error **errp)

/* Initialize the MSI IRQ allocator. */
if (!SPAPR_MACHINE_GET_CLASS(spapr)->legacy_irq_allocation) {
spapr_irq_msi_init(spapr, XICS_IRQ_BASE + nr_irqs - SPAPR_IRQ_MSI);
spapr_irq_msi_init(spapr, smc->irq->nr_msis);
}

if (kvm_enabled()) {
Expand Down Expand Up @@ -195,8 +195,13 @@ static void spapr_irq_print_info_xics(sPAPRMachineState *spapr, Monitor *mon)
ics_pic_print_info(spapr->ics, mon);
}

#define SPAPR_IRQ_XICS_NR_IRQS 0x1000
#define SPAPR_IRQ_XICS_NR_MSIS \
(XICS_IRQ_BASE + SPAPR_IRQ_XICS_NR_IRQS - SPAPR_IRQ_MSI)

sPAPRIrq spapr_irq_xics = {
.nr_irqs = XICS_IRQS_SPAPR,
.nr_irqs = SPAPR_IRQ_XICS_NR_IRQS,
.nr_msis = SPAPR_IRQ_XICS_NR_MSIS,

.init = spapr_irq_init_xics,
.claim = spapr_irq_claim_xics,
Expand Down Expand Up @@ -284,3 +289,16 @@ int spapr_irq_find(sPAPRMachineState *spapr, int num, bool align, Error **errp)

return first + ics->offset;
}

#define SPAPR_IRQ_XICS_LEGACY_NR_IRQS 0x400

sPAPRIrq spapr_irq_xics_legacy = {
.nr_irqs = SPAPR_IRQ_XICS_LEGACY_NR_IRQS,
.nr_msis = SPAPR_IRQ_XICS_LEGACY_NR_IRQS,

.init = spapr_irq_init_xics,
.claim = spapr_irq_claim_xics,
.free = spapr_irq_free_xics,
.qirq = spapr_qirq_xics,
.print_info = spapr_irq_print_info_xics,
};
8 changes: 3 additions & 5 deletions hw/ppc/spapr_pci.c
Expand Up @@ -2069,9 +2069,8 @@ static void spapr_phb_pci_enumerate(sPAPRPHBState *phb)

}

int spapr_populate_pci_dt(sPAPRPHBState *phb,
uint32_t xics_phandle,
void *fdt)
int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void *fdt,
uint32_t nr_msis)
{
int bus_off, i, j, ret;
gchar *nodename;
Expand Down Expand Up @@ -2138,8 +2137,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
_FDT(fdt_setprop(fdt, bus_off, "ranges", &ranges, sizeof_ranges));
_FDT(fdt_setprop(fdt, bus_off, "reg", &bus_reg, sizeof(bus_reg)));
_FDT(fdt_setprop_cell(fdt, bus_off, "ibm,pci-config-space-type", 0x1));
/* TODO: fine tune the total count of allocatable MSIs per PHB */
_FDT(fdt_setprop_cell(fdt, bus_off, "ibm,pe-total-#msi", XICS_IRQS_SPAPR));
_FDT(fdt_setprop_cell(fdt, bus_off, "ibm,pe-total-#msi", nr_msis));

/* Dynamic DMA window */
if (phb->ddw_enabled) {
Expand Down
27 changes: 16 additions & 11 deletions hw/scsi/lsi53c895a.c
Expand Up @@ -207,6 +207,7 @@ typedef struct {
PCIDevice parent_obj;
/*< public >*/

qemu_irq ext_irq;
MemoryRegion mmio_io;
MemoryRegion ram_io;
MemoryRegion io_io;
Expand Down Expand Up @@ -443,9 +444,19 @@ static void lsi_stop_script(LSIState *s)
s->istat1 &= ~LSI_ISTAT1_SRUN;
}

static void lsi_update_irq(LSIState *s)
static void lsi_set_irq(LSIState *s, int level)
{
PCIDevice *d = PCI_DEVICE(s);

if (s->ext_irq) {
qemu_set_irq(s->ext_irq, level);
} else {
pci_set_irq(d, level);
}
}

static void lsi_update_irq(LSIState *s)
{
int level;
static int last_level;
lsi_request *p;
Expand Down Expand Up @@ -477,7 +488,7 @@ static void lsi_update_irq(LSIState *s)
level, s->dstat, s->sist1, s->sist0);
last_level = level;
}
pci_set_irq(d, level);
lsi_set_irq(s, level);

if (!level && lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON)) {
DPRINTF("Handled IRQs & disconnected, looking for pending "
Expand Down Expand Up @@ -2213,6 +2224,7 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **errp)
"lsi-io", 256);

address_space_init(&s->pci_io_as, pci_address_space_io(dev), "lsi-pci-io");
qdev_init_gpio_out(d, &s->ext_irq, 1);

pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_io);
pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_io);
Expand Down Expand Up @@ -2277,16 +2289,9 @@ static void lsi53c895a_register_types(void)

type_init(lsi53c895a_register_types)

void lsi53c895a_create(PCIBus *bus)
{
LSIState *s = LSI53C895A(pci_create_simple(bus, -1, "lsi53c895a"));

scsi_bus_legacy_handle_cmdline(&s->bus);
}

void lsi53c810_create(PCIBus *bus, int devfn)
void lsi53c8xx_handle_legacy_cmdline(DeviceState *lsi_dev)
{
LSIState *s = LSI53C895A(pci_create_simple(bus, devfn, "lsi53c810"));
LSIState *s = LSI53C895A(lsi_dev);

scsi_bus_legacy_handle_cmdline(&s->bus);
}
5 changes: 2 additions & 3 deletions include/hw/pci-host/spapr.h
Expand Up @@ -113,9 +113,8 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)

PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index);

int spapr_populate_pci_dt(sPAPRPHBState *phb,
uint32_t xics_phandle,
void *fdt);
int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void *fdt,
uint32_t nr_msis);

void spapr_pci_rtas_init(void);

Expand Down
3 changes: 1 addition & 2 deletions include/hw/pci/pci.h
Expand Up @@ -707,8 +707,7 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);

void lsi53c895a_create(PCIBus *bus);
void lsi53c810_create(PCIBus *bus, int devfn);
void lsi53c8xx_handle_legacy_cmdline(DeviceState *lsi_dev);

qemu_irq pci_allocate_irq(PCIDevice *pci_dev);
void pci_set_irq(PCIDevice *pci_dev, int level);
Expand Down
2 changes: 2 additions & 0 deletions include/hw/ppc/spapr_irq.h
Expand Up @@ -31,6 +31,7 @@ void spapr_irq_msi_reset(sPAPRMachineState *spapr);

typedef struct sPAPRIrq {
uint32_t nr_irqs;
uint32_t nr_msis;

void (*init)(sPAPRMachineState *spapr, Error **errp);
int (*claim)(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp);
Expand All @@ -40,6 +41,7 @@ typedef struct sPAPRIrq {
} sPAPRIrq;

extern sPAPRIrq spapr_irq_xics;
extern sPAPRIrq spapr_irq_xics_legacy;

int spapr_irq_claim(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp);
void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num);
Expand Down
2 changes: 0 additions & 2 deletions include/hw/ppc/xics.h
Expand Up @@ -181,8 +181,6 @@ typedef struct XICSFabricClass {
ICPState *(*icp_get)(XICSFabric *xi, int server);
} XICSFabricClass;

#define XICS_IRQS_SPAPR 1024

void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle);

ICPState *xics_icp_get(XICSFabric *xi, int server);
Expand Down
2 changes: 2 additions & 0 deletions qapi/common.json
Expand Up @@ -140,6 +140,8 @@
# prefix to produce the corresponding QEMU executable name. This
# is true even for "qemu-system-x86_64".
#
# ppcemb: dropped in 3.1
#
# Since: 3.0
##
{ 'enum' : 'SysEmuTarget',
Expand Down

0 comments on commit 506e4a0

Please sign in to comment.