ppc: Improve multisocket support
cover ppc: Improve multisocket support
Hello,
Here are changes improving multisocket support of the XIVE models (POWER9 only). When a source has an END target on another chip, the XIVE IC will use an MMIO store to forward the notification to the remote chip. The long term plan is to get rid of pnv_xive_get_remote() whic is a modeling shortcut. I have had them for while, they compile, they seem to still work but this is not for merge yet. If someone could take over, that would be nice.
The best way to test is to start a 2 sockets * 1 cpu system with devices attached to the PCI buses of chip 0 and to offline CPU 0. All sources should be configured to be served by CPU 1 on socket 1 and trigger notifications on chip 0 should be forwarded to chip 1.
Last patch adds support for degenerative interrupts. This is used by the lowest level FW of POWER systems. Difficult to test.
Thanks,
C.
Cédric Le Goater (4):
ppc/xive: introduce a new XiveRouter end_notify() handler ppc/pnv: handle END triggers between chips with MMIOs ppc/pnv: add support for the PC MMIOs
ppc/pnv: Add support for degenerative interrupts (POWER LSI)
hw/intc/pnv_xive_regs.h | 1 + include/hw/ppc/pnv_xive.h | 15 +++ include/hw/ppc/xive.h | 3 + hw/intc/pnv_xive.c | 262 +++++++++++++++++++++++++++++++------- hw/intc/xive.c | 50 ++++++-- 5 files changed, 278 insertions(+), 53 deletions(-)
Signature · 1 line
2.41.0
RFC PATCH 1/4 ppc/xive: introduce a new XiveRouter end_notify() handler
It will help us model the END triggers on the PowerNV machine, which can be rerouted from another interrupt controller.
--- include/hw/ppc/xive.h | 2 ++ hw/intc/xive.c | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-)
include/hw/ppc/xive.h +2 -0
@@ -401,6 +401,7 @@ struct XiveRouterClass {int (*write_nvt)(XiveRouter *xrtr,uint8_t nvt_blk,uint32_t nvt_idx,XiveNVT *nvt,uint8_t word_number);uint8_t (*get_block_id)(XiveRouter *xrtr); +void (*end_notify)(XiveRouter *xrtr,XiveEAS *eas); }; int xive_router_get_eas(XiveRouter *xrtr, uint8_t eas_blk, uint32_t eas_idx,
@@ -414,6 +415,7 @@ int xive_router_get_nvt(XiveRouter *xrtr, uint8_t nvt_blk, uint32_t nvt_idx,int xive_router_write_nvt (XiveRouter *xrtr,uint8_t nvt_blk,uint32_t nvt_idx,XiveNVT *nvt,uint8_t word_number);void xive_router_notify (XiveNotifier *xn,uint32_t lisn,bool pq_checked); +void xive_router_end_notify (XiveRouter *xrtr,XiveEAS *eas);/* * XIVE Presenter
hw/intc/xive.c +18 -10
@@ -1518,6 +1518,13 @@ static void xive_router_realize(DeviceState *dev, Error **errp)assert (xrtr->xfb); } +static void xive_router_end_notify_handler (XiveRouter *xrtr,XiveEAS *eas) +{ +XiveRouterClass *xrc =XIVE_ROUTER_GET_CLASS (xrtr); + +return xrc->end_notify (xrtr, eas); +} +/* * Encode the HW CAM line in the block group mode format : *
@@ -1664,8 +1671,7 @@ static bool xive_router_end_es_notify(XiveRouter *xrtr, uint8_t end_blk,* another chip. We don't model the PowerBus but the END trigger * message has the same parameters than in the function below. */ -static void xive_router_end_notify (XiveRouter *xrtr,uint8_t end_blk, -uint32_t end_idx,uint32_t end_data) +void xive_router_end_notify (XiveRouter *xrtr,XiveEAS *eas) {XiveEND end;uint8_t priority;
@@ -1675,6 +1681,10 @@ static void xive_router_end_notify(XiveRouter *xrtr, uint8_t end_blk,XiveNVT nvt;bool found; +uint8_t end_blk =xive_get_field64 (EAS_END_BLOCK , eas->w); +uint32_t end_idx =xive_get_field64 (EAS_END_INDEX , eas->w); +uint32_t end_data =xive_get_field64 (EAS_END_DATA , eas->w); +/* END cache lookup */ if (xive_router_get_end (xrtr, end_blk, end_idx, &end)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: No END %x/%x\n", end_blk,
@@ -1817,10 +1827,7 @@ do_escalation:/* * The END trigger becomes an Escalation trigger */ -xive_router_end_notify (xrtr, -xive_get_field32 (END_W4_ESC_END_BLOCK , end.w4), -xive_get_field32 (END_W4_ESC_END_INDEX , end.w4), -xive_get_field32 (END_W5_ESC_END_DATA , end.w5)); +xive_router_end_notify_handler (xrtr, (XiveEAS *) &end.w4); }void xive_router_notify (XiveNotifier *xn,uint32_t lisn,bool pq_checked)
@@ -1871,10 +1878,7 @@ void xive_router_notify(XiveNotifier *xn, uint32_t lisn, bool pq_checked)/* * The event trigger becomes an END trigger */ -xive_router_end_notify (xrtr, -xive_get_field64 (EAS_END_BLOCK , eas.w), -xive_get_field64 (EAS_END_INDEX , eas.w), -xive_get_field64 (EAS_END_DATA , eas.w)); +xive_router_end_notify_handler (xrtr, &eas); }static Property xive_router_properties[] = {
@@ -1887,12 +1891,16 @@ static void xive_router_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);XiveNotifierClass *xnc =XIVE_NOTIFIER_CLASS (klass); +XiveRouterClass *xrc =XIVE_ROUTER_CLASS (klass); dc->desc ="XIVE Router Engine" ;device_class_set_props (dc, xive_router_properties);/* Parent is SysBusDeviceClass. No need to call its realize hook */ dc->realize = xive_router_realize; xnc->notify = xive_router_notify; + +/* By default, the router handles END triggers locally */ + xrc->end_notify = xive_router_end_notify; }static const TypeInfo xive_router_info = {
Signature · 1 line
2.41.0
RFC PATCH 2/4 ppc/pnv: handle END triggers between chips with MMIOs
In reply to Cédric Le GoaterThe notify page of the interrupt controller can either be used to receive trigger events from the HW controllers (PHB, PSI) or to reroute interrupts between Interrupt Controller. In which case, the VSD table is used to determine the address of the notify page of the remote IC and the store data is forwarded.
Today, our model grabs the remote VSD (EAS, END, NVT) address using pnv_xive_get_remote() helper but this is incorrect. EAS accesses should always be local and END triggers should be rerouted using a store on the remote IC notify page.
We still have a shortcut in the model for the NVT accesses. It will be addressed later when we model the PC mmio operations.
--- hw/intc/pnv_xive_regs.h | 1 + hw/intc/pnv_xive.c | 68 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 2 deletions(-)
hw/intc/pnv_xive_regs.h +1 -0
@@ -228,6 +228,7 @@* VSD and is only meant to be used in indirect mode ! */ #define VSD_MODE PPC_BITMASK(0, 1) +#define VSD_MODE_INVALID 0#define VSD_MODE_SHARED 1#define VSD_MODE_EXCLUSIVE 2#define VSD_MODE_FORWARD 3
hw/intc/pnv_xive.c +66 -2
104 lines not on this page · raw message
Signature · 1 line
2.41.0
RFC PATCH 3/4 ppc/pnv: add support for the PC MMIOs
In reply to Cédric Le GoaterAssociated with each NVT is a CI page address that is intended for use by privileged interrupt management code to adjust the backlog counts of a logical server and interrupt pending buffer for a specific virtual processor. This backlog count adjustment function is valuable to avoid extraneous physical interrupts when the hardware accumulates the backlog count per event queue post while the software handles multiple event queue entries on a single physical interrupt. Likewise adjusting the Interrupt Pending Buffer allows a virtual processor to process event queues of other priorities during one physical interrupt cycle.
The NVT adjustment is initiated by a store byte (stb) or a double word load instruction.
For the store byte operations that increment/decrement a backlog count the value of the data byte is the amount added (counter saturates at maximum value) / subtracted from the backlog counter (the counter does not go negative).
For the store byte operations that set/reset an IPB priority bit, the data byte is ignored.
The load double word operations that target a backlog counter increment/decrement the backlog count by one count (counter saturates at maximum value / does not go negative).
Load operations to an IPB return the pre-operation value, while load operations to a backlog counter return the post-operation value, in both cases right justified in the double word.
Programs may use the load operations if they need to know when the operation has completed; this may be accomplished by introducing a data dependency upon the returned load data. Other operation lengths (other than store byte and load double word) are not supported – results are boundedly undefined.
--- hw/intc/pnv_xive.c | 85 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 5 deletions(-)
hw/intc/pnv_xive.c +80 -5
@@ -1773,17 +1773,92 @@ static uint64_t pnv_xive_pc_read(void *opaque, hwaddr addr, unsigned size) {PnvXive *xive =PNV_XIVE (opaque); +uint32_t offset = (addr &0x1F0 ) >>4 ; +uint8_t nvt_blk; +uint32_t nvt_idx; +XiveNVT nvt; +uint8_t ipb; +uint64_t ret =-1 ; -xive_error (xive,"PC: invalid read @%" HWADDR_PRIx, addr); -return -1 ; +if (size !=8 ) { +xive_error (xive,"PC: invalid read size %d @%" HWADDR_PRIx"\n" , + size, addr); +return -1 ; + } + +/* TODO: support multi block */ + nvt_blk =pnv_xive_block_id (xive); + nvt_idx = addr >>TM_SHIFT ; + +if (xive_router_get_nvt (XIVE_ROUTER (xive), nvt_blk, nvt_idx, &nvt)) { +xive_error (xive,"PC: invalid NVT %x/%x\n" , nvt_blk, nvt_idx); +return -1 ; + } + + ipb =xive_get_field32 (NVT_W4_IPB , nvt.w4); + +switch (offset) { + case 0x0 ... 0x7: /* set IBP bit x */ + ret = ipb; + ipb |=1 << offset; +break ; + case 0x10 ... 0x17: /* reset IBP bit x */ + ret = ipb; + ipb &= ~(1 << (offset -0x10 )); +break ; + + case 0x8 ... 0xF: /* TODO: increment backlog */ +/* backlog = offset - 0x8; */ + case 0x18 ... 0x1F: /* TODO: decrement backlog */ +/* backlog = offset - 0x18; */ +default : +xive_error (xive,"PC: invalid write @%" HWADDR_PRIx"\n" , addr); + } + +if (ipb !=xive_get_field32 (NVT_W4_IPB , nvt.w4)) { + nvt.w4 =xive_set_field32 (NVT_W4_IPB , nvt.w4, ipb); +xive_router_write_nvt (XIVE_ROUTER (xive), nvt_blk, nvt_idx, &nvt,4 ); + } + +return ret; }static void pnv_xive_pc_write (void *opaque,hwaddr addr,uint64_t value,unsigned size) {PnvXive *xive =PNV_XIVE (opaque); +uint32_t offset = (addr &0x1F0 ) >>4 ; +uint8_t nvt_blk; +uint32_t nvt_idx; +XiveNVT nvt; + +if (size !=1 ) { +xive_error (xive,"PC: invalid write size %d @%" HWADDR_PRIx"\n" , + size, addr); +return ; + } + +/* TODO: support multi block */ + nvt_blk =pnv_xive_block_id (xive); + nvt_idx = addr >>TM_SHIFT ; + +if (xive_router_get_nvt (XIVE_ROUTER (xive), nvt_blk, nvt_idx, &nvt)) { +xive_error (xive,"PC: invalid NVT %x/%x\n" , nvt_blk, nvt_idx); +return ; + } -xive_error (xive,"PC: invalid write to VC @%" HWADDR_PRIx, addr); +switch (offset) { + case 0x0 ... 0x7: /* ignored */ + case 0x10 ... 0x17: /* ignored */ +break ; + + case 0x8 ... 0xF: /* TODO: Add to backlog */ +/* backlog = offset - 0x8; */ + case 0x18 ... 0x1F: /* TODO: substract to backlog */ +/* backlog = offset - 0x18; */ +default : +xive_error (xive,"PC: invalid write @%" HWADDR_PRIx"\n" , addr); + } }static const MemoryRegionOps pnv_xive_pc_ops = {
@@ -1791,11 +1866,11 @@ static const MemoryRegionOps pnv_xive_pc_ops = { .write = pnv_xive_pc_write, .endianness = DEVICE_BIG_ENDIAN, .valid = { - .min_access_size = 8, + .min_access_size = 1, .max_access_size = 8, }, .impl = { - .min_access_size = 8, + .min_access_size = 1, .max_access_size = 8, }, };
Signature · 1 line
2.41.0
RFC PATCH 4/4 ppc/pnv: Add support for degenerative interrupts (POWER LSI)
In reply to Cédric Le GoaterPOWER systems have a degenerative interrupt path used during system bring up. It doesn't rely on the XIVE routing logic and all thread 0 of each core are notified.
TODO: Need a new OS driver to check modeling.
--- include/hw/ppc/pnv_xive.h | 15 ++++++ include/hw/ppc/xive.h | 1 + hw/intc/pnv_xive.c | 109 +++++++++++++++++++++++++------------- hw/intc/xive.c | 22 ++++++++ 4 files changed, 111 insertions(+), 36 deletions(-)
include/hw/ppc/pnv_xive.h +15 -0
@@ -15,6 +15,17 @@#include "qom/object.h" #include "hw/ppc/xive2.h" +struct PnvXive ; + +#define TYPE_PNV_XIVE_LSI "pnv-xive-lsi" +#define PNV_XIVE_LSI (obj) OBJECT_CHECK(PnvXiveLsi, (obj), TYPE_PNV_XIVE_LSI) + +typedef struct PnvXiveLsi { +DeviceState parent_obj; + +struct PnvXive *xive; +}PnvXiveLsi ; +#define TYPE_PNV_XIVE "pnv-xive"OBJECT_DECLARE_TYPE (PnvXive, PnvXiveClass,PNV_XIVE )
@@ -71,6 +82,10 @@ struct PnvXive {XiveSource ipi_source;XiveENDSource end_source; +/* Lsi handlers */ +PnvXiveLsi lsi_xive; +XiveSource lsi_source; +/* Interrupt controller registers */ uint64_t regs[0x300 ];
include/hw/ppc/xive.h +1 -0
@@ -534,6 +534,7 @@ void xive_tctx_reset(XiveTCTX *tctx);void xive_tctx_destroy (XiveTCTX *tctx);void xive_tctx_ipb_update (XiveTCTX *tctx,uint8_t ring,uint8_t ipb);void xive_tctx_reset_os_signal (XiveTCTX *tctx); +void xive_tctx_lsi_notify (XiveTCTX *tctx);/* * KVM XIVE device helpers
hw/intc/pnv_xive.c +73 -36
156 lines not on this page · raw message
hw/intc/xive.c +22 -0
@@ -90,6 +90,8 @@ static uint64_t xive_tctx_accept(XiveTCTX *tctx, uint8_t ring) regs[TM_CPPR], regs[TM_NSR]); } +/* TODO: drop LP bit when LE is set */ +return (nsr <<8 ) | regs[TM_CPPR ]; }
@@ -153,6 +155,26 @@ void xive_tctx_ipb_update(XiveTCTX *tctx, uint8_t ring, uint8_t ipb)xive_tctx_notify (tctx, ring); } +void xive_tctx_lsi_notify (XiveTCTX *tctx) +{ +uint32_t qw3w2 =xive_tctx_word2 (&tctx->regs[TM_QW3_HV_PHYS ]); +uint8_t *regs = &tctx->regs[TM_QW3_HV_PHYS ]; + +/* +* If the HW context (VT) is enabled and the LSI enabled (LE) bit +* is set, raise the LSI pending bit and notify the CPU on the HV +* line. +*/ +if ((be32_to_cpu (qw3w2) & (TM_QW3W2_VT |TM_QW3W2_LE )) == + (TM_QW3W2_VT |TM_QW3W2_LE )) { + qw3w2 =xive_set_field32 (TM_QW3W2_LP , qw3w2,1 ); +memcpy (&tctx->regs[TM_QW3_HV_PHYS +TM_WORD2 ], &qw3w2,4 ); + + regs[TM_NSR ] |= (TM_QW3_NSR_HE_LSI <<6 ); +qemu_irq_raise (xive_tctx_output (tctx,TM_QW3_HV_PHYS )); + } +} +/* * XIVE Thread Interrupt Management Area (TIMA) */
Signature · 1 line
2.41.0
Quoted 10 lines · Cédric Le Goater
Hello,
Here are changes improving multisocket support of the XIVE models (POWER9 only). When a source has an END target on another chip, the XIVE IC will use an MMIO store to forward the notification to the remote chip. The long term plan is to get rid of
pnv_xive_get_remote()whic is a modeling shortcut. I have had them for while, they compile, they seem to still work but this is not for merge yet. If someone could take over, that would be nice.
Quoted 8 lines
The best way to test is to start a 2 sockets * 1 cpu system with devices attached to the PCI buses of chip 0 and to offline CPU 0. All sources should be configured to be served by CPU 1 on socket 1 and trigger notifications on chip 0 should be forwarded to chip 1.
Last patch adds support for degenerative interrupts. This is used by the lowest level FW of POWER systems. Difficult to test.
Thanks for the series! My crystal ball tells me the PC MMIO patch will come handy soon (to be adapted for P10 and groups). And the remote routing looks pretty interesting too. The last patch (LSI) may rot a bit longer though :)
Fred
Quoted 17 lines
Thanks,
C.
Cédric Le Goater (4):
ppc/xive: introduce a new XiveRouterend_notify()handler ppc/pnv: handle END triggers between chips with MMIOs ppc/pnv: add support for the PC MMIOs
ppc/pnv: Add support for degenerative interrupts (POWER LSI)hw/intc/pnv_xive_regs.h | 1 + include/hw/ppc/pnv_xive.h | 15 +++ include/hw/ppc/xive.h | 3 + hw/intc/pnv_xive.c | 262 +++++++++++++++++++++++++++++++------- hw/intc/xive.c | 50 ++++++-- 5 files changed, 278 insertions(+), 53 deletions(-)
Quoted 18 lines · Frederic Barrat
Quoted 15 lines · Cédric Le Goater
Hello,
Here are changes improving multisocket support of the XIVE models (POWER9 only). When a source has an END target on another chip, the XIVE IC will use an MMIO store to forward the notification to the remote chip. The long term plan is to get rid of
pnv_xive_get_remote()whic is a modeling shortcut. I have had them for while, they compile, they seem to still work but this is not for merge yet. If someone could take over, that would be nice.The best way to test is to start a 2 sockets * 1 cpu system with devices attached to the PCI buses of chip 0 and to offline CPU 0. All sources should be configured to be served by CPU 1 on socket 1 and trigger notifications on chip 0 should be forwarded to chip 1.
Quoted 6 lines
Quoted 3 lines
Last patch adds support for degenerative interrupts. This is used by the lowest level FW of POWER systems. Difficult to test.
Thanks for the series! My crystal ball tells me the PC MMIO patch will come handy soon (to be adapted for P10 and groups). And the remote routing looks pretty interesting too.
I am glad !
I think the first 2 patches are a good addition. They remove a qdev_get_machine() call which is ugly. P10 has the same kind of shortcut.
C.