spapr/xive: Use xive_source_esb_len()
PATCH 1/1 spapr/xive: Use xive_source_esb_len()
static inline size_t xive_source_esb_len(XiveSource *xsrc)
{
return (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
}---
Follow-up on "ppc/xive: Rework setup of XiveSource::esb_mmio"
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/
--- hw/intc/spapr_xive.c | 2 +- hw/intc/spapr_xive_kvm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/intc/spapr_xive.c +1 -1
@@ -336,7 +336,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (SYS_BUS_DEVICE (xive), &end_xsrc->esb_mmio);/* Set the mapping address of the END ESB pages after the source ESBs */ - xive->end_base = xive->vc_base + (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + xive->end_base = xive->vc_base +xive_source_esb_len (xsrc);/* * Allocate the routing tables
hw/intc/spapr_xive_kvm.c +1 -1
@@ -831,7 +831,7 @@ void kvmppc_xive_disconnect(SpaprInterruptController *intc)/* Clear the KVM mapping */ xsrc = &xive->source; - esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + esb_len =xive_source_esb_len (xsrc);if (xsrc->esb_mmap) {memory_region_del_subregion (&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
Hi Greg,
Quoted 32 lines · Greg Kurz
static inline
size_txive_source_esb_len(XiveSource *xsrc){ return (1ull << xsrc->esb_shift) * xsrc->nr_irqs; }Signed-off-by Greg Kurz <[email protected]>---
Follow-up on "ppc/xive: Rework setup ofXiveSource::esb_mmio"
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/--- hw/intc/spapr_xive.c | 2 +- hw/intc/spapr_xive_kvm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/intc/spapr_xive.c +1
-1@@ -336,7 +336,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (SYS_BUS_DEVICE (xive), &end_xsrc->esb_mmio);/* Set the mapping address of the END ESB pages after the source ESBs */ - xive->end_base = xive->vc_base + (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + xive->end_base = xive->vc_base +xive_source_esb_len (xsrc);/* * Allocate the routing tables hw/intc/spapr_xive_kvm.c +0
-0
hw/intc/spapr_xive_kvm.c void kvmppc_xive_disconnect(SpaprInterruptController *intc) · line 834
Quoted 5 lines
hw/intc/spapr_xive_kvm.c +1
-1@@ -831,7 +831,7 @@ void kvmppc_xive_disconnect(SpaprInterruptController *intc)/* Clear the KVM mapping */ xsrc = &xive->source; - esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + esb_len =xive_source_esb_len (xsrc);
hrm I'd like to not add another level of indirection here. In this specific case I think it's more clear to read just
1ull << xsrc->esb_shift) * xsrc->nr_irqs
and get the idea of one IRQ per ESB page (or pair of pages, for trigger and management), than one having to look at what is inside "a box" called xive_source_esb_len().
Wrapping it under another function doesn't help more when reading the code, XIVE is already tricky enough :)
Cheers,
Gustavo
PS: It seems something messed up with the commit message. It can be that the ML did that tho...
Quoted 2 lines · On Thu, 13 Aug 2020 17:38:59 -0300 Gustavo Romero <[email protected]>…
Hi Greg,
Hi Gustavo,
Quoted 42 lines · Greg Kurz
Quoted 32 lines
static inline
size_txive_source_esb_len(XiveSource *xsrc){ return (1ull << xsrc->esb_shift) * xsrc->nr_irqs; }Signed-off-by Greg Kurz <[email protected]>---
Follow-up on "ppc/xive: Rework setup ofXiveSource::esb_mmio"
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/--- hw/intc/spapr_xive.c | 2 +- hw/intc/spapr_xive_kvm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/intc/spapr_xive.c +1
-1@@ -336,7 +336,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (SYS_BUS_DEVICE (xive), &end_xsrc->esb_mmio);/* Set the mapping address of the END ESB pages after the source ESBs */ - xive->end_base = xive->vc_base + (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + xive->end_base = xive->vc_base +xive_source_esb_len (xsrc);/* * Allocate the routing tables hw/intc/spapr_xive_kvm.c +0
-0hw/intc/spapr_xive_kvm.c void kvmppc_xive_disconnect(SpaprInterruptController *intc) · line 834
Quoted 5 lines
hw/intc/spapr_xive_kvm.c +1
-1@@ -831,7 +831,7 @@ void kvmppc_xive_disconnect(SpaprInterruptController *intc)/* Clear the KVM mapping */ xsrc = &xive->source; - esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + esb_len =xive_source_esb_len (xsrc);hrm I'd like to not add another level of indirection here. In this specific case I think it's more clear to read just
Quoted 9 lines
1ull <<
xsrc->esb_shift) *xsrc->nr_irqsand get the idea of one IRQ per ESB page (or pair of pages, for trigger and management), than one having to look at what is inside "a box" called
xive_source_esb_len().Wrapping it under another function doesn't help more when reading the code, XIVE is already tricky enough :)
Heh, XIVE is tricky enough that only a few people will dare to touch this code and they'd better already know about the one IRQ per ESB page thingy ;-)
More seriously, this is a matter of taste, but since you're likely to be involved in XIVE a bit more than me, I'm perfectly fine with keeping this open-coded.
Quoted 6 lines
Cheers,
GustavoPS: It seems something messed up with the commit message. It can be that the ML did that tho...
It's more laziness on my side... I should have come up with a proper changelog like "We already have an helper that provides the length of the ESB mapping. No need to open-code this again." instead of pasting a code snippet. Time to go on vacation I guess :)
Cheers,
--
Greg
Quoted 56 lines · Greg Kurz
Quoted 2 lines · On Thu, 13 Aug 2020 17:38:59 -0300 Gustavo Romero <[email protected]>…
Hi Greg,
Hi Gustavo,
Quoted 48 lines · Greg Kurz
Quoted 32 lines
static inline
size_txive_source_esb_len(XiveSource *xsrc){ return (1ull << xsrc->esb_shift) * xsrc->nr_irqs; }Signed-off-by Greg Kurz <[email protected]>---
Follow-up on "ppc/xive: Rework setup ofXiveSource::esb_mmio"
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/--- hw/intc/spapr_xive.c | 2 +- hw/intc/spapr_xive_kvm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/intc/spapr_xive.c +1
-1@@ -336,7 +336,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (SYS_BUS_DEVICE (xive), &end_xsrc->esb_mmio);/* Set the mapping address of the END ESB pages after the source ESBs */ - xive->end_base = xive->vc_base + (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + xive->end_base = xive->vc_base +xive_source_esb_len (xsrc);/* * Allocate the routing tables hw/intc/spapr_xive_kvm.c +0
-0hw/intc/spapr_xive_kvm.c void kvmppc_xive_disconnect(SpaprInterruptController *intc) · line 834
Quoted 5 lines
hw/intc/spapr_xive_kvm.c +1
-1@@ -831,7 +831,7 @@ void kvmppc_xive_disconnect(SpaprInterruptController *intc)/* Clear the KVM mapping */ xsrc = &xive->source; - esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + esb_len =xive_source_esb_len (xsrc);hrm I'd like to not add another level of indirection here. In this specific case I think it's more clear to read just
1ull <<
xsrc->esb_shift) *xsrc->nr_irqsand get the idea of one IRQ per ESB page (or pair of pages, for trigger and management), than one having to look at what is inside "a box" called
xive_source_esb_len().
Quoted 7 lines
Quoted 3 lines
Wrapping it under another function doesn't help more when reading the code, XIVE is already tricky enough :)
Heh, XIVE is tricky enough that only a few people will dare to touch this code and they'd better already know about the one IRQ per ESB page thingy ;-)
Yea, maybe someday we get a cool documentation on it.
Luckily I came after Benh and Cédric and took some good info from OPAL and QEMU code. I found out recently that XIVE support was merged into FreeBSD and with that it also came some good comments about xive...
Quoted 3 lines
More seriously, this is a matter of taste, but since you're likely to be involved in XIVE a bit more than me, I'm perfectly fine with keeping this open-coded.
Thanks, Greg.
Hope there is still some time to enjoy the summer over there :)
Cheers,
Gustavo
Quoted 3 lines
I found out recently that XIVE support was
merged into FreeBSD and with that it also came some good comments about xive...
cool ! Does it run in a QEMU PowerNV machine ?
C.
David Gibson
AppliedQuoted 41 lines · Gustavo Romero
Hi Greg,
Quoted 30 lines · Greg Kurz
static inline
size_txive_source_esb_len(XiveSource *xsrc){ return (1ull << xsrc->esb_shift) * xsrc->nr_irqs; }Signed-off-by Greg Kurz <[email protected]>---
Follow-up on "ppc/xive: Rework setup ofXiveSource::esb_mmio"
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/--- hw/intc/spapr_xive.c | 2 +- hw/intc/spapr_xive_kvm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/intc/spapr_xive.c +1
-1@@ -336,7 +336,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (SYS_BUS_DEVICE (xive), &end_xsrc->esb_mmio);/* Set the mapping address of the END ESB pages after the source ESBs */ - xive->end_base = xive->vc_base + (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + xive->end_base = xive->vc_base +xive_source_esb_len (xsrc);/* * Allocate the routing tables hw/intc/spapr_xive_kvm.c +0
-0hw/intc/spapr_xive_kvm.c void kvmppc_xive_disconnect(SpaprInterruptController *intc) · line 833
Quoted 4 lines
hw/intc/spapr_xive_kvm.c +1
-1@@ -831,7 +831,7 @@ void kvmppc_xive_disconnect(SpaprInterruptController *intc)/* Clear the KVM mapping */ xsrc = &xive->source; - esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs; + esb_len =xive_source_esb_len (xsrc);hrm I'd like to not add another level of indirection here. In this specific case I think it's more clear to read just
Quoted 8 lines
1ull <<
xsrc->esb_shift) *xsrc->nr_irqsand get the idea of one IRQ per ESB page (or pair of pages, for trigger and management), than one having to look at what is inside "a box" called
xive_source_esb_len().Wrapping it under another function doesn't help more when reading the code, XIVE is already tricky enough :)
Given that we're already using it in some places, I'd prefer to use it in all the places that it's correct to do so.
Applied to ppc-for-5.2.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson