ARM SMMUv3: Fix event queue handling and memory region names
cover ARM SMMUv3: Fix event queue handling and memory region names
This series fixes the event queue handling: the events were incorrectly recorded and the interrupt was not sent as expected.
Also we fix the IOMMU memory region names. This last issue is minor as names only are used for debug/tracing. However it can be confusing.
Best Regards
Eric
Eric Auger (2):
hw/arm/smmu-common: Fix the name of the iommu memory regions hw/arm/smmuv3: fix eventq recording and IRQ triggerring
hw/arm/smmu-common.c | 6 +++--- hw/arm/smmuv3-internal.h | 26 +++++++++++++------------- hw/arm/smmuv3.c | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 hw/arm/smmu-common: Fix the name of the iommu memory regions
At the point smmu_find_add_as() gets called, the bus number might not be computed. Let's change the name of IOMMU memory region and just use the devfn and an incrementing index.
The name only is used for debug.
--- hw/arm/smmu-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/arm/smmu-common.c +3 -3
@@ -311,6 +311,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)SMMUState *s = opaque;SMMUPciBus *sbus =g_hash_table_lookup (s->smmu_pcibus_by_busptr, bus);SMMUDevice *sdev; +static uint index;if (!sbus) { sbus = g_malloc0(sizeof(SMMUPciBus) +
@@ -321,9 +322,8 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) sdev = sbus->pbdev[devfn];if (!sdev) { -char *name =g_strdup_printf ("%s-%d-%d" , - s->mrtypename, -pci_bus_num (bus), devfn); +char *name =g_strdup_printf ("%s-%d-%d" , s->mrtypename, devfn, index++); + sdev = sbus->pbdev[devfn] =g_new0 (SMMUDevice,1 ); sdev->smmu = s;
Signature · 1 line
2.17.1
Re: [Qemu-arm] [PATCH 1/2] hw/arm/smmu-common: Fix the name of the iommu memory regions
Quoted 16 lines · Eric Auger
At the point
smmu_find_add_as()gets called, the bus number might not be computed. Let's change the name of IOMMU memory region and just use the devfn and an incrementing index.The name only is used for debug.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmu-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/arm/smmu-common.c +0
-0
hw/arm/smmu-common.c static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) · line 314
Quoted 4 lines
hw/arm/smmu-common.c +1
-0@@ -311,6 +311,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)SMMUState *s = opaque;SMMUPciBus *sbus =g_hash_table_lookup (s->smmu_pcibus_by_busptr, bus);SMMUDevice *sdev; +static uint index;
"uint" isn't a standard type (and causes a build failure on at least one of my build systems). Did you mean "unsigned int" ?
thanks
-- PMM
Re: [Qemu-arm] [PATCH 1/2] hw/arm/smmu-common: Fix the name of the iommu memory regions
Hi Peter,
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Eric Auger
At the point
smmu_find_add_as()gets called, the bus number might not be computed. Let's change the name of IOMMU memory region and just use the devfn and an incrementing index.The name only is used for debug.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmu-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 12 lines
hw/arm/smmu-common.c static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) · line 314
Quoted 9 lines
hw/arm/smmu-common.c +1
-0@@ -311,6 +311,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)SMMUState *s = opaque;SMMUPciBus *sbus =g_hash_table_lookup (s->smmu_pcibus_by_busptr, bus);SMMUDevice *sdev; +static uint index;"uint" isn't a standard type (and causes a build failure on at least one of my build systems). Did you mean "unsigned int" ?
Hum yes, I did. Shall I repost or do you fix it directly?
Thanks
Eric
Quoted 4 lines
thanks
-- PMM
Re: [Qemu-arm] [PATCH 1/2] hw/arm/smmu-common: Fix the name of the iommu memory regions
Quoted 27 lines · Auger Eric
Hi Peter,
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Eric Auger
At the point
smmu_find_add_as()gets called, the bus number might not be computed. Let's change the name of IOMMU memory region and just use the devfn and an incrementing index.The name only is used for debug.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmu-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Quoted 12 lines
hw/arm/smmu-common.c static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) · line 314
Quoted 9 lines
hw/arm/smmu-common.c +1
-0@@ -311,6 +311,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)SMMUState *s = opaque;SMMUPciBus *sbus =g_hash_table_lookup (s->smmu_pcibus_by_busptr, bus);SMMUDevice *sdev; +static uint index;"uint" isn't a standard type (and causes a build failure on at least one of my build systems). Did you mean "unsigned int" ?
Quoted 1 line
Hum yes, I did. Shall I repost or do you fix it directly?
I've fixed it up in my v2 pull request.
thanks
-- PMM
Re: [Qemu-arm] [PATCH 1/2] hw/arm/smmu-common: Fix the name of the iommu memory regions
Hi Peter,
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Auger Eric
Hi Peter,
Quoted 24 lines · Peter Maydell
Quoted 16 lines · Eric Auger
At the point
smmu_find_add_as()gets called, the bus number might not be computed. Let's change the name of IOMMU memory region and just use the devfn and an incrementing index.The name only is used for debug.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmu-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/arm/smmu-common.c +0
-0hw/arm/smmu-common.c static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) · line 314
Quoted 4 lines
hw/arm/smmu-common.c +1
-0@@ -311,6 +311,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)SMMUState *s = opaque;SMMUPciBus *sbus =g_hash_table_lookup (s->smmu_pcibus_by_busptr, bus);SMMUDevice *sdev; +static uint index;"uint" isn't a standard type (and causes a build failure on at least one of my build systems). Did you mean "unsigned int" ?
Quoted 3 lines
Quoted 1 line
Hum yes, I did. Shall I repost or do you fix it directly?
I've fixed it up in my v2 pull request.
OK thanks!
Eric
Quoted 4 lines
thanks
-- PMM
PATCH 2/2 hw/arm/smmuv3: fix eventq recording and IRQ triggerring
In reply to Eric AugerThe event queue management is broken today. Event records are not properly written as EVT_SET_* macro was not updating the actual event record. Also the event queue interrupt is not correctly triggered.
--- hw/arm/smmuv3-internal.h | 26 +++++++++++++------------- hw/arm/smmuv3.c | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-)
hw/arm/smmuv3-internal.h +13 -13
@@ -442,17 +442,17 @@ typedef struct SMMUEventInfo {#define EVT_Q_OVERFLOW (1 << 31) -#define EVT_SET_TYPE (x, v) deposit32((x)->word[0], 0 , 8 , v) -#define EVT_SET_SSV (x, v) deposit32((x)->word[0], 11, 1 , v) -#define EVT_SET_SSID (x, v) deposit32((x)->word[0], 12, 20, v) -#define EVT_SET_SID (x, v) ((x)->word[1] = v) -#define EVT_SET_STAG (x, v) deposit32((x)->word[2], 0 , 16, v) -#define EVT_SET_STALL (x, v) deposit32((x)->word[2], 31, 1 , v) -#define EVT_SET_PNU (x, v) deposit32((x)->word[3], 1 , 1 , v) -#define EVT_SET_IND (x, v) deposit32((x)->word[3], 2 , 1 , v) -#define EVT_SET_RNW (x, v) deposit32((x)->word[3], 3 , 1 , v) -#define EVT_SET_S2 (x, v) deposit32((x)->word[3], 7 , 1 , v) -#define EVT_SET_CLASS (x, v) deposit32((x)->word[3], 8 , 2 , v) +#define EVT_SET_TYPE (x, v) ((x)->word[0] = deposit32((x)->word[0], 0 , 8 , v)) +#define EVT_SET_SSV (x, v) ((x)->word[0] = deposit32((x)->word[0], 11, 1 , v)) +#define EVT_SET_SSID (x, v) ((x)->word[0] = deposit32((x)->word[0], 12, 20, v)) +#define EVT_SET_SID (x, v) ((x)->word[1] = v) +#define EVT_SET_STAG (x, v) ((x)->word[2] = deposit32((x)->word[2], 0 , 16, v)) +#define EVT_SET_STALL (x, v) ((x)->word[2] = deposit32((x)->word[2], 31, 1 , v)) +#define EVT_SET_PNU (x, v) ((x)->word[3] = deposit32((x)->word[3], 1 , 1 , v)) +#define EVT_SET_IND (x, v) ((x)->word[3] = deposit32((x)->word[3], 2 , 1 , v)) +#define EVT_SET_RNW (x, v) ((x)->word[3] = deposit32((x)->word[3], 3 , 1 , v)) +#define EVT_SET_S2 (x, v) ((x)->word[3] = deposit32((x)->word[3], 7 , 1 , v)) +#define EVT_SET_CLASS (x, v) ((x)->word[3] = deposit32((x)->word[3], 8 , 2 , v))#define EVT_SET_ADDR (x, addr) \ do { \ (x)->word[5] = (uint32_t)(addr >> 32); \
@@ -460,8 +460,8 @@ typedef struct SMMUEventInfo { } while (0)#define EVT_SET_ADDR2 (x, addr) \ do { \ - deposit32((x)->word[7], 3, 29, addr >> 16); \ - deposit32((x)->word[7], 0, 16, addr & 0xffff);\ + (x)->word[7] = deposit32((x)->word[7], 3, 29, addr >> 16); \ + (x)->word[7] = deposit32((x)->word[7], 0, 16, addr & 0xffff);\ } while (0)void smmuv3_record_event (SMMUv3State *s,SMMUEventInfo *event);
hw/arm/smmuv3.c +1 -1
@@ -136,7 +136,7 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, Evt *evt)return r; } -if (smmuv3_q_empty (q)) { +if (!smmuv3_q_empty (q)) {smmuv3_trigger_irq (s,SMMU_IRQ_EVTQ ,0 ); }return MEMTX_OK ;
Signature · 1 line
2.17.1
Re: [Qemu-arm] [PATCH 2/2] hw/arm/smmuv3: fix eventq recording and IRQ triggerring
Quoted 32 lines · Eric Auger
The event queue management is broken today. Event records are not properly written as EVT_SET_* macro was not updating the actual event record. Also the event queue interrupt is not correctly triggered.
Fixes bb981004eaf4 ("hw/arm/smmuv3: Event queue recording helper")Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3-internal.h | 26 +++++++++++++------------- hw/arm/smmuv3.c | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-)hw/arm/smmuv3-internal.h +1
-11@@ -442,17 +442,17 @@ typedef struct SMMUEventInfo {#define EVT_Q_OVERFLOW (1 << 31) -#define EVT_SET_TYPE (x, v) deposit32((x)->word[0], 0 , 8 , v) -#define EVT_SET_SSV (x, v) deposit32((x)->word[0], 11, 1 , v) -#define EVT_SET_SSID (x, v) deposit32((x)->word[0], 12, 20, v) -#define EVT_SET_SID (x, v) ((x)->word[1] = v) -#define EVT_SET_STAG (x, v) deposit32((x)->word[2], 0 , 16, v) -#define EVT_SET_STALL (x, v) deposit32((x)->word[2], 31, 1 , v) -#define EVT_SET_PNU (x, v) deposit32((x)->word[3], 1 , 1 , v) -#define EVT_SET_IND (x, v) deposit32((x)->word[3], 2 , 1 , v) -#define EVT_SET_RNW (x, v) deposit32((x)->word[3], 3 , 1 , v) -#define EVT_SET_S2 (x, v) deposit32((x)->word[3], 7 , 1 , v) -#define EVT_SET_CLASS (x, v) deposit32((x)->word[3], 8 , 2 , v) +#define EVT_SET_TYPE (x, v) ((x)->word[0] = deposit32((x)->word[0], 0 , 8 , v))
hw/arm/smmuv3-internal.h typedef struct SMMUEventInfo { · line 455
Quoted 10 lines
hw/arm/smmuv3-internal.h +10
-0+#define EVT_SET_SSV (x, v) ((x)->word[0] = deposit32((x)->word[0], 11, 1 , v)) +#define EVT_SET_SSID (x, v) ((x)->word[0] = deposit32((x)->word[0], 12, 20, v)) +#define EVT_SET_SID (x, v) ((x)->word[1] = v) +#define EVT_SET_STAG (x, v) ((x)->word[2] = deposit32((x)->word[2], 0 , 16, v)) +#define EVT_SET_STALL (x, v) ((x)->word[2] = deposit32((x)->word[2], 31, 1 , v)) +#define EVT_SET_PNU (x, v) ((x)->word[3] = deposit32((x)->word[3], 1 , 1 , v)) +#define EVT_SET_IND (x, v) ((x)->word[3] = deposit32((x)->word[3], 2 , 1 , v)) +#define EVT_SET_RNW (x, v) ((x)->word[3] = deposit32((x)->word[3], 3 , 1 , v)) +#define EVT_SET_S2 (x, v) ((x)->word[3] = deposit32((x)->word[3], 7 , 1 , v)) +#define EVT_SET_CLASS (x, v) ((x)->word[3] = deposit32((x)->word[3], 8 , 2 , v))
Oops. I'm a bit embarrassed I didn't notice that in code review...
thanks
-- PMM
Re: [Qemu-arm] [PATCH 2/2] hw/arm/smmuv3: fix eventq recording and IRQ triggerring
Hi Peter,
Quoted 38 lines · Peter Maydell
Quoted 37 lines · Eric Auger
The event queue management is broken today. Event records are not properly written as EVT_SET_* macro was not updating the actual event record. Also the event queue interrupt is not correctly triggered.
Fixes bb981004eaf4 ("hw/arm/smmuv3: Event queue recording helper")Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3-internal.h | 26 +++++++++++++------------- hw/arm/smmuv3.c | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-)hw/arm/smmuv3-internal.h +6
-11@@ -442,17 +442,17 @@ typedef struct SMMUEventInfo {#define EVT_Q_OVERFLOW (1 << 31) -#define EVT_SET_TYPE (x, v) deposit32((x)->word[0], 0 , 8 , v) -#define EVT_SET_SSV (x, v) deposit32((x)->word[0], 11, 1 , v) -#define EVT_SET_SSID (x, v) deposit32((x)->word[0], 12, 20, v) -#define EVT_SET_SID (x, v) ((x)->word[1] = v) -#define EVT_SET_STAG (x, v) deposit32((x)->word[2], 0 , 16, v) -#define EVT_SET_STALL (x, v) deposit32((x)->word[2], 31, 1 , v) -#define EVT_SET_PNU (x, v) deposit32((x)->word[3], 1 , 1 , v) -#define EVT_SET_IND (x, v) deposit32((x)->word[3], 2 , 1 , v) -#define EVT_SET_RNW (x, v) deposit32((x)->word[3], 3 , 1 , v) -#define EVT_SET_S2 (x, v) deposit32((x)->word[3], 7 , 1 , v) -#define EVT_SET_CLASS (x, v) deposit32((x)->word[3], 8 , 2 , v) +#define EVT_SET_TYPE (x, v) ((x)->word[0] = deposit32((x)->word[0], 0 , 8 , v)) +#define EVT_SET_SSV (x, v) ((x)->word[0] = deposit32((x)->word[0], 11, 1 , v)) +#define EVT_SET_SSID (x, v) ((x)->word[0] = deposit32((x)->word[0], 12, 20, v)) +#define EVT_SET_SID (x, v) ((x)->word[1] = v) +#define EVT_SET_STAG (x, v) ((x)->word[2] = deposit32((x)->word[2], 0 , 16, v)) +#define EVT_SET_STALL (x, v) ((x)->word[2] = deposit32((x)->word[2], 31, 1 , v))
Quoted 8 lines
hw/arm/smmuv3-internal.h typedef struct SMMUEventInfo { · line 455
Quoted 5 lines
hw/arm/smmuv3-internal.h +5
-0+#define EVT_SET_PNU (x, v) ((x)->word[3] = deposit32((x)->word[3], 1 , 1 , v)) +#define EVT_SET_IND (x, v) ((x)->word[3] = deposit32((x)->word[3], 2 , 1 , v)) +#define EVT_SET_RNW (x, v) ((x)->word[3] = deposit32((x)->word[3], 3 , 1 , v)) +#define EVT_SET_S2 (x, v) ((x)->word[3] = deposit32((x)->word[3], 7 , 1 , v)) +#define EVT_SET_CLASS (x, v) ((x)->word[3] = deposit32((x)->word[3], 8 , 2 , v))Oops. I'm a bit embarrassed I didn't notice that in code review...
Well I am even more embarrassed than you ;-) Usually there are no faults. When I got some, mostly due to emulation code bugs, I mostly focused on QEMU guest_errors logs. I noticed the code was broken when attempting to report faults from host smmu driver. Sorry for the inconvenience.
Thanks
Eric
Quoted 4 lines
thanks
-- PMM
Peter Maydell
AppliedQuoted 9 lines · Eric Auger
This series fixes the event queue handling: the events were incorrectly recorded and the interrupt was not sent as expected.
Also we fix the IOMMU memory region names. This last issue is minor as names only are used for debug/tracing. However it can be confusing.
Best Regards
Eric
Applied to target-arm.next, thanks.
-- PMM