qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

ppc/pnv: add a LPC Controller model for POWER10

Same a POWER9, only the MMIO window changes.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191205184454.10722-6-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

authored by

Cédric Le Goater and committed by
David Gibson
2661f6ab 8b50ce85

+53 -12
+22 -3
hw/ppc/pnv.c
··· 314 314 pnv_dt_memory(fdt, chip->chip_id, chip->ram_start, chip->ram_size); 315 315 } 316 316 317 - pnv_dt_lpc(chip, fdt, 0); 317 + pnv_dt_lpc(chip, fdt, 0, PNV9_LPCM_BASE(chip), PNV9_LPCM_SIZE); 318 318 } 319 319 320 320 static void pnv_chip_power10_dt_populate(PnvChip *chip, void *fdt) ··· 332 332 if (chip->ram_size) { 333 333 pnv_dt_memory(fdt, chip->chip_id, chip->ram_start, chip->ram_size); 334 334 } 335 + 336 + pnv_dt_lpc(chip, fdt, 0, PNV10_LPCM_BASE(chip), PNV10_LPCM_SIZE); 335 337 } 336 338 337 339 static void pnv_dt_rtc(ISADevice *d, void *fdt, int lpc_off) ··· 601 603 602 604 static ISABus *pnv_chip_power10_isa_create(PnvChip *chip, Error **errp) 603 605 { 604 - error_setg(errp, "No ISA bus!"); 605 - return NULL; 606 + Pnv10Chip *chip10 = PNV10_CHIP(chip); 607 + return pnv_lpc_isa_create(&chip10->lpc, false, errp); 606 608 } 607 609 608 610 static ISABus *pnv_isa_create(PnvChip *chip, Error **errp) ··· 1315 1317 1316 1318 object_initialize_child(obj, "psi", &chip10->psi, sizeof(chip10->psi), 1317 1319 TYPE_PNV10_PSI, &error_abort, NULL); 1320 + object_initialize_child(obj, "lpc", &chip10->lpc, sizeof(chip10->lpc), 1321 + TYPE_PNV10_LPC, &error_abort, NULL); 1318 1322 } 1319 1323 1320 1324 static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) ··· 1349 1353 } 1350 1354 pnv_xscom_add_subregion(chip, PNV10_XSCOM_PSIHB_BASE, 1351 1355 &PNV_PSI(&chip10->psi)->xscom_regs); 1356 + 1357 + /* LPC */ 1358 + object_property_set_link(OBJECT(&chip10->lpc), OBJECT(&chip10->psi), "psi", 1359 + &error_abort); 1360 + object_property_set_bool(OBJECT(&chip10->lpc), true, "realized", 1361 + &local_err); 1362 + if (local_err) { 1363 + error_propagate(errp, local_err); 1364 + return; 1365 + } 1366 + memory_region_add_subregion(get_system_memory(), PNV10_LPCM_BASE(chip), 1367 + &chip10->lpc.xscom_regs); 1368 + 1369 + chip->dt_isa_nodename = g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0", 1370 + (uint64_t) PNV10_LPCM_BASE(chip)); 1352 1371 } 1353 1372 1354 1373 static void pnv_chip_power10_class_init(ObjectClass *klass, void *data)
+22 -8
hw/ppc/pnv_lpc.c
··· 122 122 } 123 123 124 124 /* POWER9 only */ 125 - int pnv_dt_lpc(PnvChip *chip, void *fdt, int root_offset) 125 + int pnv_dt_lpc(PnvChip *chip, void *fdt, int root_offset, uint64_t lpcm_addr, 126 + uint64_t lpcm_size) 126 127 { 127 128 const char compat[] = "ibm,power9-lpcm-opb\0simple-bus"; 128 129 const char lpc_compat[] = "ibm,power9-lpc\0ibm,lpc"; 129 130 char *name; 130 131 int offset, lpcm_offset; 131 - uint64_t lpcm_addr = PNV9_LPCM_BASE(chip); 132 132 uint32_t opb_ranges[8] = { 0, 133 133 cpu_to_be32(lpcm_addr >> 32), 134 134 cpu_to_be32((uint32_t)lpcm_addr), 135 - cpu_to_be32(PNV9_LPCM_SIZE / 2), 136 - cpu_to_be32(PNV9_LPCM_SIZE / 2), 135 + cpu_to_be32(lpcm_size / 2), 136 + cpu_to_be32(lpcm_size / 2), 137 137 cpu_to_be32(lpcm_addr >> 32), 138 - cpu_to_be32(PNV9_LPCM_SIZE / 2), 139 - cpu_to_be32(PNV9_LPCM_SIZE / 2), 138 + cpu_to_be32(lpcm_size / 2), 139 + cpu_to_be32(lpcm_size / 2), 140 140 }; 141 141 uint32_t opb_reg[4] = { cpu_to_be32(lpcm_addr >> 32), 142 142 cpu_to_be32((uint32_t)lpcm_addr), 143 - cpu_to_be32(PNV9_LPCM_SIZE >> 32), 144 - cpu_to_be32((uint32_t)PNV9_LPCM_SIZE), 143 + cpu_to_be32(lpcm_size >> 32), 144 + cpu_to_be32((uint32_t)lpcm_size), 145 145 }; 146 146 uint32_t lpc_ranges[12] = { 0, 0, 147 147 cpu_to_be32(LPC_MEM_OPB_ADDR), ··· 691 691 .class_init = pnv_lpc_power9_class_init, 692 692 }; 693 693 694 + static void pnv_lpc_power10_class_init(ObjectClass *klass, void *data) 695 + { 696 + DeviceClass *dc = DEVICE_CLASS(klass); 697 + 698 + dc->desc = "PowerNV LPC Controller POWER10"; 699 + } 700 + 701 + static const TypeInfo pnv_lpc_power10_info = { 702 + .name = TYPE_PNV10_LPC, 703 + .parent = TYPE_PNV9_LPC, 704 + .class_init = pnv_lpc_power10_class_init, 705 + }; 706 + 694 707 static void pnv_lpc_realize(DeviceState *dev, Error **errp) 695 708 { 696 709 PnvLpcController *lpc = PNV_LPC(dev); ··· 764 777 type_register_static(&pnv_lpc_info); 765 778 type_register_static(&pnv_lpc_power8_info); 766 779 type_register_static(&pnv_lpc_power9_info); 780 + type_register_static(&pnv_lpc_power10_info); 767 781 } 768 782 769 783 type_init(pnv_lpc_register_types)
+4
include/hw/ppc/pnv.h
··· 115 115 116 116 /*< public >*/ 117 117 Pnv9Psi psi; 118 + PnvLpcController lpc; 118 119 } Pnv10Chip; 119 120 120 121 typedef struct PnvChipClass { ··· 328 329 329 330 #define PNV10_XSCOM_SIZE 0x0000000400000000ull 330 331 #define PNV10_XSCOM_BASE(chip) PNV10_CHIP_BASE(chip, 0x00603fc00000000ull) 332 + 333 + #define PNV10_LPCM_SIZE 0x0000000100000000ull 334 + #define PNV10_LPCM_BASE(chip) PNV10_CHIP_BASE(chip, 0x0006030000000000ull) 331 335 332 336 #define PNV10_PSIHB_ESB_SIZE 0x0000000000100000ull 333 337 #define PNV10_PSIHB_ESB_BASE(chip) PNV10_CHIP_BASE(chip, 0x0006030202000000ull)
+5 -1
include/hw/ppc/pnv_lpc.h
··· 31 31 #define TYPE_PNV9_LPC TYPE_PNV_LPC "-POWER9" 32 32 #define PNV9_LPC(obj) OBJECT_CHECK(PnvLpcController, (obj), TYPE_PNV9_LPC) 33 33 34 + #define TYPE_PNV10_LPC TYPE_PNV_LPC "-POWER10" 35 + #define PNV10_LPC(obj) OBJECT_CHECK(PnvLpcController, (obj), TYPE_PNV10_LPC) 36 + 34 37 typedef struct PnvLpcController { 35 38 DeviceState parent; 36 39 ··· 97 100 struct PnvChip; 98 101 99 102 ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp); 100 - int pnv_dt_lpc(struct PnvChip *chip, void *fdt, int root_offset); 103 + int pnv_dt_lpc(struct PnvChip *chip, void *fdt, int root_offset, 104 + uint64_t lpcm_addr, uint64_t lpcm_size); 101 105 102 106 #endif /* PPC_PNV_LPC_H */