s390x/pci: add common fmb
PATCH v7 1/1 s390x/pci: add common fmb
After the last review round I and use the sizeof of the source entry in the fmb_do_update() function instead of the target entry. Anyway they both are the same size but it may be easier to read.
Regards,
Pierre
Yi Min Zhao (1):
s390x/pci: add common function measurement block
hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)
Signature · 44 lines
2.7.4 Changelog: from v6: - let the compiler calculate the sizeof target entry using the source size (was using target size) but of course they should (and are) the same from v5: - let the compiler calculate the sizeof target entry. from v4: - commit message - use sizeof target of the fmb_do_update from v3: - changed commit message according to Conny's comments In s390-pci-inst.c - simplify the fmb_do_update() to handle all cases from byte to quad. (Conny) from v2: In s390-pci-bus: - Initialize the FMB Format. In s390-pci-bus.h - re-organization of the internal counters, having a table for the internal counters. In s390-pci-inst.c - Internal counters update (LD/ST/STB/RPCIT) is done always. even if the FMB if fmb_addr is NULL. AFAIU this respect the documentation which only states that FMB update is stopped. - in mpcifc_service_call(), moved the setting of fmb_addr after the timer has been stopped. - fmb_update((), use address_space_stq_be() to handle endianness when storing the FMB. - define the format with 32 bits instead of one char and reserved chars, this is easier to handle the FMB copy. - No update of the DMA fields inside the FMB, as stipulated by the documentation when format32 is 0.
PATCH v7 1/1 s390x/pci: add common function measurement block
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.
--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)
hw/s390x/s390-pci-bus.c +3 -1
@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);s390_pci_msix_free (pbdev);s390_pci_iommu_free (s, bus, devfn); pbdev->pdev =NULL ;
@@ -1136,6 +1137,7 @@ static void s390_pci_device_realize(DeviceState *dev, Error **errp) } zpci->state =ZPCI_FS_RESERVED ; + zpci->fmb.format =ZPCI_FMB_FORMAT ; }static void s390_pci_device_reset (DeviceState *dev)
@@ -1160,7 +1162,7 @@ static void s390_pci_device_reset(DeviceState *dev)pci_dereg_ioat (pbdev->iommu); } - pbdev->fmb_addr =0 ; +fmb_timer_free (pbdev); } static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name,
hw/s390x/s390-pci-bus.h +29 -0
@@ -286,6 +286,33 @@ typedef struct S390PCIIOMMUTable {S390PCIIOMMU *iommu[PCI_SLOT_MAX ]; } S390PCIIOMMUTable; +/* Function Measurement Block */ +#define DEFAULT_MUI 4000 +#define UPDATE_U_BIT 0x1ULL +#define FMBK_MASK 0xfULL + +typedef struct ZpciFmbFmt0 { +uint64_t dma_rbytes; +uint64_t dma_wbytes; +}ZpciFmbFmt0 ; + +#define ZPCI_FMB_CNT_LD 0 +#define ZPCI_FMB_CNT_ST 1 +#define ZPCI_FMB_CNT_STB 2 +#define ZPCI_FMB_CNT_RPCIT 3 +#define ZPCI_FMB_CNT_MAX 4 + +#define ZPCI_FMB_FORMAT 0 + +typedef struct ZpciFmb { +uint32_t format; +uint32_t sample; +uint64_t last_update; +uint64_t counter[ZPCI_FMB_CNT_MAX ]; +ZpciFmbFmt0 fmt0; +}ZpciFmb ; +QEMU_BUILD_BUG_MSG (offsetof(ZpciFmb , fmt0) !=48 ,"padding in ZpciFmb" ); +struct S390PCIBusDevice {DeviceState qdev;PCIDevice *pdev;
@@ -297,6 +324,8 @@ struct S390PCIBusDevice {uint32_t fid;bool fid_defined;uint64_t fmb_addr; +ZpciFmb fmb; +QEMUTimer *fmb_timer;uint8_t isc;uint16_t noi;uint16_t maxstbl;
hw/s390x/s390-pci-inst.c +130 -3
182 lines not on this page · raw message
hw/s390x/s390-pci-inst.h +1 -0
@@ -303,6 +303,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, uintptr_t ra);int stpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba,uint8_t ar,uintptr_t ra); +void fmb_timer_free (S390PCIBusDevice *pbdev);#define ZPCI_IO_BAR_MIN 0#define ZPCI_IO_BAR_MAX 5
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
Quoted 33 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)hw/s390x/s390-pci-bus.c +0
-0
hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 4 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);
I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
Quoted 29 lines · David Hildenbrand
Quoted 28 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)
Quoted 14 lines
hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 9 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
... but I see the issue. It boils down to the bad design of zPCI. The PCI device has no clue about the pbdev. So this has to stay here because in unrealize of pbdev it would be wrong and into unrealize of pci_dev, we can't move it.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
Quoted 45 lines · David Hildenbrand
Quoted 29 lines · David Hildenbrand
Quoted 28 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)Quoted 14 lines
hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 9 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
Quoted 5 lines
... but I see the issue. It boils down to the bad design of zPCI. The PCI device has no clue about the pbdev. So this has to stay here because in unrealize of pbdev it would be wrong and into unrealize of
pci_dev, we can't move it.
OK, thanks.
So is it a ack from you?
regards,
Pierre
Signature · 2 lines
Pierre Morel Linux/KVM/QEMU in Böblingen - Germany
David Hildenbrand
Acked-byRe: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
Quoted 46 lines · Pierre Morel
Quoted 45 lines · David Hildenbrand
Quoted 43 lines · David Hildenbrand
Quoted 33 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)hw/s390x/s390-pci-bus.c +0
-0hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 4 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
Quoted 8 lines
Quoted 5 lines
... but I see the issue. It boils down to the bad design of zPCI. The PCI device has no clue about the pbdev. So this has to stay here because in unrealize of pbdev it would be wrong and into unrealize of
pci_dev, we can't move it.OK, thanks.
So is it a ack from you?
:)
Quoted 4 lines
regards,
Pierre
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
Quoted 53 lines · David Hildenbrand
Quoted 52 lines · Pierre Morel
Quoted 50 lines · David Hildenbrand
Quoted 29 lines · David Hildenbrand
Quoted 28 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)Quoted 14 lines
hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 9 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
... but I see the issue. It boils down to the bad design of zPCI. The PCI device has no clue about the pbdev. So this has to stay here because in unrealize of pbdev it would be wrong and into unrealize of
pci_dev, we can't move it.
Quoted 7 lines
Quoted 2 lines
OK, thanks.
So is it a ack from you?:)
:)
thanks
Pierre
Quoted 6 lines
Quoted 4 lines
regards,
Pierre
Signature · 2 lines
Pierre Morel Linux/KVM/QEMU in Böblingen - Germany
Re: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
In reply to David HildenbrandQuoted 53 lines · On Mon, 14 Jan 2019 10:23:58 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 52 lines · Pierre Morel
Quoted 50 lines · David Hildenbrand
Quoted 29 lines · David Hildenbrand
Quoted 28 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)Quoted 14 lines
hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 9 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
... but I see the issue. It boils down to the bad design of zPCI. The PCI device has no clue about the pbdev. So this has to stay here because in unrealize of pbdev it would be wrong and into unrealize of
pci_dev, we can't move it.
Quoted 6 lines
Quoted 2 lines
OK, thanks.
So is it a ack from you?:)
Great!
Still waiting for an ack from Collin (nudge, nudge :) before applying this.
Re: [Qemu-devel] [qemu-s390x] [PATCH v7] s390x/pci: add common function measurement block
Quoted 59 lines · Cornelia Huck
Quoted 56 lines · On Mon, 14 Jan 2019 10:23:58 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 54 lines · Pierre Morel
Quoted 45 lines · David Hildenbrand
Quoted 29 lines · David Hildenbrand
Quoted 28 lines · Pierre Morel
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)Quoted 14 lines
hw/s390x/s390-pci-bus.c static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, · line 992
Quoted 9 lines
hw/s390x/s390-pci-bus.c +1
-0@@ -989,6 +989,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev, bus =pci_get_bus (pci_dev); devfn = pci_dev->devfn;object_unparent (OBJECT (pci_dev)); +fmb_timer_free (pbdev);I still think this is the wrong place. it has nothing to do with hotplug/unplug. This belongs into unrealize/finalize.
Quoted 5 lines
... but I see the issue. It boils down to the bad design of zPCI. The PCI device has no clue about the pbdev. So this has to stay here because in unrealize of pbdev it would be wrong and into unrealize of
pci_dev, we can't move it.OK, thanks.
So is it a ack from you?
Quoted 9 lines
Quoted 3 lines
:)
Great!
Still waiting for an ack from Collin (nudge, nudge :) before applying this.
Whoops, thought I already acked this one -- sorry!
I give this my full Reviewed-by: Collin Walling <[email protected]>
Cornelia Huck
AppliedRe: [Qemu-devel] [PATCH v7] s390x/pci: add common function measurement block
In reply to Pierre MorelQuoted 19 lines · On Tue, 8 Jan 2019 18:37:30 +0100 Pierre Morel <[email protected]> wrote:
From: Yi Min Zhao <[email protected]>
Common function measurement block is used to report zPCI internal counters of successful pcilg/stg/stb and rpcit instructions to a memory location provided by the program.
This patch introduces a new ZpciFmb structure and schedules a timer callback to copy the zPCI measures to the FMB in the guest memory at an interval time set to 4s.
An error while attemping to update the FMB, would generate an error event to the guest.
The pcilg/stg/stb and rpcit interception handlers increase the related counter on a successful call.
The guest shall pass a null FMBA (FMB address) in the FIB (Function Information Block) when it issues a Modify PCI Function Control instruction to switch off FMB and stop the corresponding timer.
Quoted 8 lines
Signed-off-by Yi Min Zhao <[email protected]>Signed-off-by Pierre Morel <[email protected]>--- hw/s390x/s390-pci-bus.c | 4 +- hw/s390x/s390-pci-bus.h | 29 +++++++++++ hw/s390x/s390-pci-inst.c | 133 +++++++++++++++++++++++++++++++++++++++++++++-- hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 163 insertions(+), 4 deletions(-)
Thanks, applied.